02-03-2021 12:25 AM
Hi ,
I have an array which i want to sort it by the keys/column.
{
array1:[
{
" Width":“4”
" Length":“5 "
" Item Desc”:"Black ",
" Item ":"Pen "
},
{
"Width":"5"
" Length":"7 "
" Item Desc":"Blue ",
" Item ":"Pen " ,
}
]
}
Output:-
{
array1:[
{
" Item ":“Pen " ,
" Item Desc”:"Black “,
" Length”:“5 "
" Width”:“4”
},
{
" Item Desc":"Blue ",
" Item ":"Pen "
" Length":"7 "
"Width":"5"
}
02-03-2021 10:39 AM
Hi,
You can use the expression that’s in the mapper in the attached pipelinesort_2021_02_03.slp (3.5 KB) to sort the the elements.
02-03-2021 11:01 AM
Here’s a simpler expression that will work with any number of keys without modification:
$array1.map(e => e.entries().sort().toObject(x => x[0], x => x[1]))