Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: event.target parent 
Javascript :: react bootstrap card 
Javascript :: check if a checkbox is checked jquery 
Javascript :: moment day in range 
Javascript :: how to reverse a string in javascript 
Javascript :: react native flatlist 
Javascript :: how to change the tab text in React 
Javascript :: TypeError: MiniCssExtractPlugin is not a constructor 
Javascript :: convert object to boolean javascript 
Javascript :: httpclientmodule is not an angular module 
Javascript :: object delete with id filter javascript 
Javascript :: electron no menu bar 
Javascript :: javascript how to raise the error 
Javascript :: link in angular 
Javascript :: allow cors express 
Javascript :: js get current function name 
Javascript :: traverse an array in javascript 
Javascript :: async storage get item 
Javascript :: jquery remove attribute 
Javascript :: react native scrollview detect end 
Javascript :: react onclick with event 
Javascript :: react native release apk command 
Javascript :: how to get time and date from iso string javascript 
Javascript :: react-native-reanimated npm 
Javascript :: javascript get url parameters 
Javascript :: how to get all form values in javascript 
Javascript :: jquery select div in div 
Javascript :: npm for node types 
Javascript :: javascript check if string is valid hex color 
Javascript :: revert back to css 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =