# Sorting multidimensional array

**URL:** <https://forum.kirupa.com/t/sorting-multidimensional-array/52620>\
**Category:** Uncategorized\
**Created:** [May 25, 2004, 8:24pm UTC](https://forum.kirupa.com/t/sorting-multidimensional-array/52620 "2004-05-25T20:24:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boondogger](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@Boondogger](https://forum.kirupa.com/u/Boondogger)\
**Post date:** [May 25, 2004, 8:24pm UTC](https://forum.kirupa.com/t/sorting-multidimensional-array/52620/1 "2004-05-25T20:24:06Z")

</div>

I have an array of objects (the first member of each object is a string which records the object’s name) The other members of the objects contain various numerical information. I need to sort each category of information and display the names next to their related information in correct numerical order:  
ie. AName 4235  
AnotherOne 3962  
OneMore 1576

Can anyone suggest some code which would do this? I checked out .sort and .onSort, built in methods of array but I can’t get my head round it.There are thirteen objects in my array. The fourth element (population) needs to be sorted. I tried  
x=0;  
for (i=0;i\<14;i++) {//counts through objects in array  
if ( EmpireList \* [3] \>x)  
x= EmpireList \* [3];//loops through array to find greatest numerical value  
} //and writes it into x  
LargestInArray = x;

This gave me the biggest numerical element in the array. I figured I needed some kind of nested for loop to find the next largest and so on but I can’t get it to work.

Ideally I need to copy the information into a new array with two dimensions (for name and information)

Thanks

MD
