Sign in to follow this  
Followers 0
Phaser

_ArraySort, only 1st digit sorted

5 posts in this topic

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

_ArraySortNum() by SmOke_N perfect thanks GEOSoft

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  
Followers 0