Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created July 28, 2009 03:08
Show Gist options
  • Save lsmith/156898 to your computer and use it in GitHub Desktop.
Save lsmith/156898 to your computer and use it in GitHub Desktop.
_sort: function(nodes) {
if (nodes) {
nodes = NativeSelector._toArray(nodes);
if (nodes.sort) {
var indices = [], i;
for (i = nodes.length - 1; i >= 0; --i) {
indices[i] = { i:i, idx:Y.DOM.srcIndex(nodes[i]) };
}
indices.sort(function(a, b) {
return a.idx - b.idx;
});
for (i = indices.length - 1; i >= 0; --i) {
indices[i] = nodes[indices.i];
}
nodes = indices;
}
}
return nodes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment