Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to stop the eval sorting in IE9

    in IE9 Browser list of country names sorting on keys.
    we are using Ajax
    javascript:
    Code:
    var data= remoteRequest(url);
    the data like
    Code:
    data={" 11":"Australia"," 14":"Bermuda"," CAN":"Canada"," 12":"France"," 15":"Germany"," IND":"India"," 16":"Russia"," 13":"South Africa"," 10":"UK"," USA":"United States"}
    name_set= eval('('+data+')');
    it fine in all browser
    the array like
    Code:
    name_set[11]=Australia
    name_set[14]=Bermuda
    name_set[CAN]=Canada
    name_set[12]=France
    name_set[15]=Germany
    name_set[IND]=India
    name_set[16]=Russia
    name_set[13]=South Africa
    name_set[10]=UK
    name_set[USA]=United States
    but in the IE9 browser array keys sorting as like.
    Code:
    name_set[10]=UK
    name_set[11]=Australia
    name_set[12]=France
    name_set[13]=South Africa
    name_set[14]=Bermuda
    name_set[15]=Germany
    name_set[16]=Russia
    name_set[CAN]=Canada
    name_set[IND]=India
    name_set[USA]=United States
    so please help me, how to stop the array sorting in IE9.

    thanks in Advance,
    Venu
    Last edited by Kor; 07-06-2011 at 04:50 PM. Reason: wrap the code [code][/code]

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    What you have there is an Object (that means an unsorted, unordered list) not an Array (which is an ordered list).

    See the difference:
    http://json.org

    As long as you are dealing with an object, it does not matter too much in which order the pairs property:value are arranged, because you can not circle through them using and indent. An Object has no length.

    But if, for a reason or another, you need that pairs to be sorted upon the value, not upon the key (property) why don't you sort them using a sorting algorithm? Do you need such a code?
    Last edited by Kor; 07-06-2011 at 04:48 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    By the way: I can not confirm that "sorting" you are talking about. In my IE9 there is no such a "sorting".

    And your data should look as a string (see the blue quotes), like:
    Code:
    var data='{" 11":"Australia"," 14":"Bermuda"," CAN":"Canada"," 12":"France"," 15":"Germany"," IND":"India"," 16":"Russia"," 13":"South Africa"," 10":"UK"," USA":"United States"}';
    otherwise what's the point of evaluating it? The way you have written it, there is straight a JSON object.
    Last edited by Kor; 07-06-2011 at 05:03 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Hi

    Hi Venu Did you find the solution? Please let me know

    Thanks,
    Bhaskar


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •