tags:

views:

60

answers:

3

Hi all, 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

A: 

What is that for a question ?

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

streetparade
Sorry,I want to sort the Object Json by keys number 2 under alphanumericI have problem with english sorry
A: 
        json.sort(function(a, b) {
            if (json.2 < json.2) return -1;
            if (json.2 > json.2) return 1;
            return 0;
        });
Ralph Stevens
ThanksErreur : missing ) after conditionif (json.2 < json.2) return -1;
A: 

Converted to Array :) more simple.

Thanks ;)