maccman/spine — pull request #399 by laserlemon (2012-12-08 00:19:59+00:00)
Title: Fix model ordering bug in Chrome (and others?)

In Chrome, when an object's keys are numeric (`1`, `2`, `3`) or even numeric strings (`"1"`, `"2"`, `"3"`), the object is automatically sorted.

```
> records = {"asdf": "First", "sdfg": "Second", "dfgh": "Third"}
> for (id in records){ console.log(records[id]); }
First
Second
Third
> records = {"1234": "First", "3456": "Second", "2345": "Third"}
> for (id in records){ console.log(records[id]); }
First
Third
Second
```

In Spine models, instances of that model are stored in the `@records` object and if the IDs of the instances are numeric, the records are automatically rearranged by Chrome, making `all`, `each`, `select`, etc. all assume the incorrect order.

These changes add the `@ids` array to the model to keep a reference to the intended order. Theses IDs are maintained throughout creations, destructions, deletions and ID changes.

An Ajax Spine model may fetch its instances from the server, specifying an attribute by which the server should sort the results. In the case where the collection is paginated, this sorting cannot simply be done on the client side. In such a case, preserving the intended order of the fetched instances is important.

Hope this helps! It's my first contribution to a JavaScript project. Thank you!