Jump to content
Sign in to follow this  

sort list by reverse alphabetical order

Recommended Posts


hello everyone,

i know that $LBS_SORT is a style that forces a list to be sorted alphabetically, and if i remove this style, the list is sorted by the order in which items are added. but i don't see any options of controlling the sorting. for example, to my current needs, what is the best way to sort a list in reverse alphabetical order?

thanks in advance,


Share this post

Link to post
Share on other sites

It then becomes time to get an array involved.

If you are already creating the list from an array you are half there, otherwise you have 2 choices. Create an array with your items in it or use StringSplit() to create an array from the list then _ArraySort(), then convert it back to a string. Of course you don't want to use the $LBS_SORT or it won't work.


Global $sData, $aData
$sData = "Apples|Oranges|Pears"
$aData = StringSplit($sData, "|", 2)
_ArraySort($aData, 1)
$sData = _ArrayToString($aData)

Global $hMyList = GUICtrlCreateList("", 10, 10 , 100, 100)
GUICtrlSetData($hMyList, $sData)


If you made the mistake of using a 1 based array to create the list originally then you have to change

$sData = _ArrayToString($aData)
$sData = _ArrayToString($aData, "|", 1)
and don't forget if you didn't use "|" for the delimiter you also have to change the second parameter to use whatever your delimiter was. Edited by GEOSoft


Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver: - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this