Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angularjs How to sort a specific value in a map

var map = new Map();
map.set('0001', {lastChat: {message: 'test', time: 1640063014931}});
map.set('0002', {lastChat: {message: 'test', time: 1640063014930}});

var sortedMap = new Map([...map].sort((a, b) => a[1].lastChat.time - b[1].lastChat.time));

console.log(sortedMap.entries())
//Output : MapIterator {'0002' => {…}, '0001' => {…}}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Easy Angular way to detect if element is in viewport on scroll 
Javascript :: Angular Frontend - How do I change a value I got from backend in frontend 
Javascript :: Porting Promise.all functionality from AngularJs to VueJs 
Javascript :: createaction ngrx example 
Javascript :: Angular js set default tab with ng-repeat in array object 
Javascript :: I am getting an error "createSpyObj requires a non-empty array" with running unit tests, which were executed perfectly before 
Javascript :: react-native navigation stack set push component then cover parent page 
Javascript :: javascript unique grouped arrays 
Javascript :: how to send more than one array using response() json() in laravel 
Javascript :: mutexify 
Javascript :: get lat long from address google api 
Javascript :: JavaScript delete atray item 
Javascript :: Special Chars like DOTS in Express.js route 
Javascript :: select the value of dropdownMenu with Semantic ui react 
Javascript :: get range of items in list javascript react native 
Javascript :: nodejs passport starter template with username and password 
Javascript :: online convert javascript to typescript 
Javascript :: Example: How to use || operator to shorten the code. 
Javascript :: creating hashblock method using sha256 hashing algorithm 
Javascript :: javascript check if a number starts with another number 
Javascript :: Second Simplest Promise Example 
Javascript :: repeated click onchange javascript 
Javascript :: prisma count non-null 
Javascript :: jQuery Misc Methods 
Javascript :: Get year from user entered date in javascript 
Javascript :: destructuring array es6 
Javascript :: get the first recurring character javascript 
Javascript :: how to change array elements position in array in javascript 
Javascript :: radio button remove checked 
Javascript :: redirect router v6 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =