# _ArraySort, only 1st digit sorted

## Recommended Posts

Hi Guys

This isn't stopping me from accomplishing what I wanted BUT its annoying me a little, I am building 1 array out of 6 arrays using _ArrayConcatenate() builds fine, but after that I want to sort it it is sorting but not fully

13,49,28,3,76,11,42,72

is becoming

11,13,28,3,42,49,72,76

I would prefer

3,11,13 etc

Why is it doing the above, like treating each digit individually

##### Share on other sites

I know exactly what is wrong. I dont know how to fix it properly, but it is sorting it in numerical order like so.

Look at the first character in all of the values and sort accordingly.

Look at second character and sort accordingly.

So it gets something like 11,1,2,12

and turns it into 1,11,12,2 when it should be 1,2,11,12

The only way I see this being fixed would be like so;

13,49,28,03,76,11,42,72

Or something like that, as I dont personally know any other way to do it.

##### Share on other sites

Yes you are correct, BUT, before I used _ArrayConcatenate() to build the array it was working fine, I was using _ArrayAdd prior to that but decided concatenate would be quicker/neater maybe?

##### Share on other sites

It's because _ArraySort is a "String" sort so that is the correct order but what you want is a "numeric" sort. Try _ArraySortNum() by SmOke_N

http://www.autoitscript.com/forum/index.php?s=&showtopic=40618&view=findpost&p=302369

George

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:3.0.1.13) - 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 on other sites

_ArraySortNum() by SmOke_N perfect thanks GEOSoft

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...