Jump to content

Recommended Posts

Posted

Hello,

1.png.806104cc20f156062aeed82eb4d0a6e1.png2.png.08584cfee9c78952b4036a092e4d1296.png
 

#include <array.au3>

Global $test[4][3] = [["Jax",100,3],["Jade",50,1],["Jaquie",70,0],["Sonya",80,2]]

_ArrayDisplay($test)

Is there a quick way of sorting the array in ascending
order with the values from column three?

thanks in advance

Posted

I think _ArraySort sorts in alpha-numeric order - That may be why your array with 1000 entries didn't appear to be sorted.

After running this:

#include <Array.au3>

Global $g_eaNames[4] = [ 'Jax', 'Jade', 'Jaquie', 'Sonya' ]
Global $g_aArray[0][3]

For $i = 1 To 1000 Step 1
    Local $sName = $g_eaNames[Random(0, (UBound($g_eaNames) - 1), 1)]
    Local $iInteger1 = Random(1, 100, 1)
    Local $iInteger2 = Random(1, 1000, 1)
    _ArrayAdd($g_aArray, $sName & Chr(124) & _
                         $iInteger1 & Chr(124) & _
                         $iInteger2)
Next

_ArraySort($g_aArray, 0, Default, Default, 2)
_ArrayDisplay($g_aArray)

The Output was:

image.png.375d1d92a63da408bda22019674c5a69.png

Notice how 1000 is before 102.

  • 2 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...