The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on February 24, 2009, 06:01:17 PM

Title: Unicode version of string sorting
Post by: Farabi on February 24, 2009, 06:01:17 PM
Anyone know what function I should use to do Unicode string sorting?
Title: Re: Unicode version of string sorting
Post by: donkey on February 26, 2009, 09:17:49 AM
Depends on how many strings you are looking to sort, if it's really a large number your probably best off to write your own sort routine. Different algorithms perform better on different types of data, find the one that's right for yours. If its a relatively small number of strings (<200 or so) you can just use the DPA functions from common controls, pretty slow but quick to implement an array. Note this code is in GoAsm format with STRINGS UNICODE:

invoke InitCommonControls

invoke DPA_Create,64
mov [hDPA],eax

invoke DPA_InsertPtr,[hDPA],0,offset L"abcdef"
invoke DPA_InsertPtr,[hDPA],0,offset L"kdafjla"
invoke DPA_InsertPtr,[hDPA],0,offset L"oasdjs"
invoke DPA_InsertPtr,[hDPA],0,offset L"ejsdjf"
invoke DPA_InsertPtr,[hDPA],0,offset L"ihjsdhi"
invoke DPA_InsertPtr,[hDPA],0,offset L"4sdfsad"
invoke DPA_Sort,[hDPA],offset FNDPACOMPARE, NULL

...

FNDPACOMPARE FRAME p1,p2,lParam
invoke lstrcmp,[p1],[p2]
RET
ENDF


Avoid the DSA string functions, some versions of common controls are missing the DSA_Sort function.
Title: Re: Unicode version of string sorting
Post by: Farabi on February 26, 2009, 12:55:07 PM
What is DPA?
Title: Re: Unicode version of string sorting
Post by: donkey on February 26, 2009, 02:00:01 PM
The Dynamic Pointer Array API.