sort nested data using sort function javascript
var sort = function (prop, arr) {
prop = prop.split('.');
var len = prop.length;
arr.sort(function (a, b) {
var i = 0;
while( i < len ) { a = a[prop[i]]; b = b[prop[i]]; i++; }
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
});
return arr;
};
Also in JavaScript:
- MVC view pass model to javascript function
- app.listen express
- angular material spinner with logo
- for each python json
- react mui icons
- how to use for of in javascript
- cambiar background image javascript
- redux http library
- next js newsletter
- how to get value and key in a for of loop in js
- javascript sort multidimensional array
- how to count specific letters in string js
- contact form7 404 wp-json feedback
- share data between livewire and alpine js
- how to make graphql request in axios
- jquery ajax responseText
- js takes a string of words and returns the highest scoring word.
- if json then parse
- count word and space in text javascript
- concat array javascript
- how to add role in discord.js v12
- how to get user's machine and browser through js
- nodejs self quit program
- Javascript case insensitive string comparison