var a = {prop: 3, name: 'a'}, b = {prop: 2, name: 'b'}, c = {prop: 1, name: 'c'}; var array = [ a, b, c ], result = null; result = array.sort(function(a, b){ var c = a.prop, d = b.prop; if( c < b ){ return -1; }else if( c > b ){ return 1; } return 0; }); for(var i in result){ console.log(result[i].name); // a, b, c } That doesn't work ...
Added by:
And in js so you can not sort? And what's the difference sort that move places?