2

I'm getting an object of values as a response to $.get

 $.get('www.example.com/get-data/', {'data': $('form').serialize()}, function (data) {
            $.each(data, function (key, value) {
                console.log(key,value);
            });
...

I'm facing different order on different devices = on desktop Safari 8.0 it returns me the following order:

10 R10
15 R15
16 R16

But it returns reversed order on mobile safari (iOS 6)

16 R16    
15 R15
10 R10

Does anybody know why? I've also tried to sort returned object:

> data
Object {10: "R10", 15: "R15", 16: "R16"}
> data.sort()
TypeError: undefined is not a function

Do you know how to sort this object to keep alphabetical order on all devices? I need to keep "key => value" definition is there any other way then using an array of objects? For example

[{10:"R10"},{15:"R15"},{16:"R16"}]
emte
  • 647
  • 1
  • 8
  • 25

0 Answers0