Sort function same as Excel?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Sort function same as Excel?

05 Sep 2020, 11:51

Hi,

I'm trying to sort a list but it does not sort correctly or same as Excel does. Any idea on how to sort same as Excel does?

Example of data in the list sorted by Sort, varname
94-996
95-305
B256-13508
B455-32438
13-041
13-044
13-061
13-15

Example of data in the list sorted by Excel
13-041
13-044
13-061
13-15
94-996
95-305
B256-13508
B455-32438
User avatar
flyingDman
Posts: 2832
Joined: 29 Sep 2013, 19:01

Re: Sort function same as Excel?

05 Sep 2020, 13:54

I am not sure that your first set is the result of a simple sort, varname. Post your script.
14.3 & 1.3.7
User avatar
mikeyww
Posts: 27191
Joined: 09 Sep 2014, 18:38

Re: Sort function same as Excel?

05 Sep 2020, 14:02

Code: Select all

items := "94-996,95-305,B256-13508,B455-32438,13-041,13-044,13-061,13-15"
Sort items, D,
MsgBox, 64, Sorted items, These are your sorted items:`n`n%items%
maitresin
Posts: 45
Joined: 20 Mar 2018, 19:33

Re: Sort function same as Excel?

05 Sep 2020, 15:00

Code: Select all

fileread, Missing, Missing.txt
sort, Missing, D,

filedelete, Missing.txt

Fileappend,
(
%Missing%
),Missing.txt
User avatar
boiler
Posts: 17206
Joined: 21 Dec 2014, 02:44

Re: Sort function same as Excel?

05 Sep 2020, 15:23

Your Sort command says to make the delimiter a comma. Your list is not separated by commas. Change it to use the default delimiters (line breaks) like this:

Code: Select all

Sort, Missing
Demo:

Code: Select all

Missing =
(
94-996
95-305
B256-13508
B455-32438
13-041
13-044
13-061
13-15
)

Sort, Missing
MsgBox, % Missing
User avatar
flyingDman
Posts: 2832
Joined: 29 Sep 2013, 19:01

Re: Sort function same as Excel?

05 Sep 2020, 16:42

That confirms my suspicion.
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: pgeugene and 166 guests