Jump to content

Sorting Multidimensional Array


peterhuynh
Go to solution Solved by Barand,

Recommended Posts

Hi, supernoob here. This is my 2nd thread. The 1st one was very helpful.

 

I want to sort a multidimensional array.

 

I have something like this:

 

{"bids": [[ 100, 24 ], [ 300, 10 ], [ 200, 34 ]], "asks": [[ 300, 23 ], [ 100, 34 ], [ 200, 21]]}

 

I want to order "bids" such that the largest first number in the square brackets goes first. (I realize I'm not explaining this well.) For example, I want "[[ 300, 10 ], [ 200, 34 ], [ 100, 24 ]]".

 

And I want to order "asks" such that the smallest first number in the square bracket goes first. For example, I want "[[ 100, 34 ], [ 200, 21 ], [ 300, 23]]"

 

 

 

Thank you so much!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.