Jump to content
Sign in to follow this  
BigGrayBeast

Sorting 2 dimension array

Recommended Posts

BigGrayBeast

If I had this array and first names, last names, and wives names:

a[1][1] = "John"

a[1][2] = "Doe"

a[1][3] = "Ann"

a[2][1] = "Bill"

a[2][2] = "Adams"

a[2][3] = "Joanne"

How would I sort by Last name?

Thanks

Share this post


Link to post
Share on other sites
randallc

Hi,

Hard to know which are your lastnames!

Try;

;array2dsortex.au3
#include <Array.au3>
local  $arGrid[3][2] =[["Bill", "Clinton"],["John", "Huskins"], ["George", "Bush"]]
_ArrayDisplay($arGrid, "Before Sort");, 1, 1); [2D, transposed]
;_ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )
_ArraySort($arGrid,0,0,UBound($arGrid,1)-1,UBound($arGrid,2),UBound($arGrid,2)-1)
_ArrayDisplay($arGrid, "After Sort on ASC surnames;_ArraySort($arGrid,0,0,UBound($arGrid,1)-1,UBound($arGrid,2),UBound($arGrid,2)-1)");, 1, 1); [2D, transposed]
_ArraySort($arGrid,1,0,UBound($arGrid,1)-1,UBound($arGrid,2),UBound($arGrid,2)-1)
_ArrayDisplay($arGrid, "After Sort on DESC surnames;_ArraySort($arGrid,1,0,UBound($arGrid,1)-1,UBound($arGrid,2),UBound($arGrid,2)-1)");, 1, 1); [2D, transposed]
Best, Randall Edited by randallc

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  

×