I have object
which also has object
as a value. I want to sort that object
based on 'copy' key value. fiddle
var x= {'one':{'copy':'b'},'two':{'copy':'v'},'three':{'copy':'a'}}
var getsort= []
for(i in x){
var a= new Object();
a[i]=x[i]
getsort.push(a)
}
getsort.sort(function(a,b){
//console.log(b)
//console.log(a.copy)
var textA = a.copy.toUpperCase();
var textB = b.copy.toUpperCase();
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
})
console.log(getsort)