Sorting a value pair in Javascript

Posted by Bradley M. Davis on Stack Overflow See other posts from Stack Overflow or by Bradley M. Davis
Published on 2012-09-25T03:23:47Z Indexed on 2012/09/25 3:37 UTC
Read the original article Hit count: 201

I must be missing the proper term or else I'm sure I could find the answer by searching... in any case, here's what I want to do.

Through javascript, I get four variables (A, B, C, and D) that I would like to sort, and still keep track of the variable name (since it's encoded with meaning information).

Sample Data:

A = 2;
B = 1;
C = 4;
D = 3;

What I need to do now is sort them in value order (4,3,2,1) such that I can actually know the variable name ordering (C,D,A,B).

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about sorting