Sort List Alphabetically Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKd00b

Sort List Alphabetically  Topic is solved

16 May 2018, 16:04

Hello there, I've created a script that uses COM to cycle through previous/next values on an Excel column AutoFilter. I've gotten it to work quite well except for the part that sorts the values from the selected column before storing them into an array. The way that Excel sorts its row values is not the same as a regular Alphabetical sorting. Please see example codes:

Code: Select all

list =      
(
500
5
4-Series
360
3
2-Series
260
2
1-Series
190
124 Spider
)

Sort, list, F StringSort            ;Sort function

;Sort Function Output:              How Excel sorts the same list:
;   1-Series                            124 Spider
;   124 Spider                          190
;   2                                   1-Series
;   190                                 2
;   2-Series                            260
;   3                                   2-Series
;   260                                 3
;   360                                 360
;   4-Series                            4-Series
;   5                                   5
;   500                                 500

;Sort function I used found in AHK documentation
StringSort(a1, a2)
{
    return a1 > a2 ? 1 : a1 < a2 ? -1 : 0  ; Sorts alphabetically based on the setting of StringCaseSense.
}    
As you can see the sort order does not match how Excel does its sorting. The sort order in my script needs to be identical to Excel's sort method so when the list is inserted into an Array, the index value of each row should match with Excel so I can accurately call each value by using its index.

Any ideas on how to solve this? Perhaps someone has a sort function that already does this? Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 325 guests