Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort json in descending order

const data = [
    {id: 1, name: "Bob", email: "example@email.com"},
    {id: 2, name: "Tom", email: "example@email.com"},
    {id: 3, name: "Cat", email: "example@email.com"},
    {id: 4, name: "Mat", email: "example@email.com"},
	{id: 5, name: "Tim", email: "example@email.com"},
];

let sortedData = data.slice().sort((a, b) => b.id - a.id);
console.log(sortedData);
 
PREVIOUS NEXT
Tagged: #sort #json #descending #order
ADD COMMENT
Topic
Name
7+4 =