0

On litle and complex question, I want to sort a multilevel Json Object,I'm using Jquery

var json = {
    "x18561":
    {
            "0":"18561","1":"MPD182","2":"Sony Ericsson bejoo ","3":"xxxxxx"
    },
    "x18562":
    {
            "0":"18562","1":"MPD181","2":"Samsung Playerone S5230 ","3":"yyyyyy"
    }
    ,
    "x18562":
    {
            "0":"18562","1":"MPD183","2":"Samsung Aero ","3":"yyyyyy"
    }


json.sort(1,alphaORnumeric); //what?


     var rez = '';

     for (var key in json) {
            rez += json[key][2]+', ';
    }

alert(rez); // return : Samsung Aero, Sony Ericsson, Samsung Playerone S5230 

What can I'm using for : json.sort(1,alphaORnumeric);

I want to sort the Object Json by keys number 2 under alphanumeric I have problem with english sorry

Thanks a lot for your help

pagetronic
  • 41
  • 1
  • 7

2 Answers2

0

What is that for a question ?

What can I'm using for : json.sort(1,alphaORnumeric);

streetparade
  • 32,000
  • 37
  • 101
  • 123
  • Sorry, I want to sort the Object Json by keys number 2 under alphanumeric I have problem with english sorry – pagetronic Jan 21 '10 at 19:20
0
        json.sort(function(a, b) {
            if (json.2 < json.2) return -1;
            if (json.2 > json.2) return 1;
            return 0;
        });
stepanian
  • 11,373
  • 8
  • 43
  • 63