-2

Lets say I have an object:

    var testobject = { 
      '1100': {
        name: 'Jane',
        status: '3'
      },
      '2000': {
        name: 'Jack',
        status: '1'
      },
      '1000': {
        name: 'Jason',
        status: '5'
      }
    };

What is the best way to sort it by 'status' value? To get order like this:

    { 
      '2000': {
        name: 'Jack',
        status: '1'
      },
      '1100': {
        name: 'Jane',
        status: '3'
      },
      '1000': {
        name: 'Jason',
        status: '5'
      }
    };

Thanks a lot.

1
  • objects aren't sorted, you could use a map see this answer Commented Jun 11, 2021 at 15:16

1 Answer 1

0

Thanks, maps are exactly what I was looking for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.