2D array sort

# Thread: 2D array sort

1. Member
Join Date
Dec 1969
Posts
50

## 2D array sort

Hello fellow ASPer<BR><BR>I am trying to sort a 2-D array say:<BR><BR> arr2D(0,0) = "George"<BR> arr2D(1,0) = "W."<BR> arr2D(2,0) = "Washington"<BR><BR> arr2D(0,1) = "Daniel"<BR> arr2D(1,1) = "K."<BR> arr2D(2,1) = "Joseph"<BR><BR>If I do<BR> arr2D = SortArray(arr2D)<BR> <BR>The result is<BR> arr2D(0,0) = "Daniel"<BR> arr2D(1,0) = "K."<BR> arr2D(2,0) = "Joseph"<BR><BR> arr2D(0,1) = "George"<BR> arr2D(1,1) = "W."<BR> arr2D(2,1) = "Washington"<BR><BR>Kind off like sort by last name. <BR><BR>Question: Will Javascript sort function do it for you like it does for 1D array? If it does anyone know the syntax to pass the array into Javascript function to sort by the 1st field--ie arr2D(0,record#).<BR><BR>Thank you.

2. Member
Join Date
Dec 1969
Posts
50

## solution

I&#039;ve found a solution:<BR><BR>I basically just convert it to a 1D array with some special joining character say &#124# so you&#039;ll end up with something like<BR> arr1D(0) = "George &#124# W. &#124# Washington"<BR> arr1D(1) = "Daniel &#124# K. &#124# Joseph"<BR>then I just use java sort to do same sorting and split the arr1D back later for display (I also think can be split back into 2D array as well--just haven&#039;t found a need for yet).<BR><BR>If you have better solution. Sure would like to hear your comment.<BR><BR>Thanks

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•