News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Unicode version of string sorting

Started by Farabi, February 24, 2009, 06:01:17 PM

Previous topic - Next topic

Farabi

Anyone know what function I should use to do Unicode string sorting?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

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.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable