javascript - Lodash sortByOrder with provided alphabet -


i need sort array of objects provided keys. sorting must case-insensitive , use provided alphabet. example let's take initial data looks this:

var notordered = [{   date: "11-12-2015",   name: "tomasz",   age: 50,   products: "fdgs",   rate: 500 }, {   date: "12-11-2015",   name: "Łukasz",   age: 54,   products: "Łbdgs",   rate: 110 }, {   date: "11-12-2015",   name: "jan",   age: 24,   products: "Żdgs",   rate: 1000 }, {   date: "11-12-2015",   name: "Łucja",   age: 18,   products: "aebdgs",   rate: 50 }];  var keys = ["date", "rate", "name"]; var directions = [true, false, true]; var alphabet = '01234567989aąbcćdeęfghijklłmnńoóprsśtuvwxyzźż' 

so result i'm looking is:

var ordered = [{   date: "11-12-2015",   name: "Łucja",   age: 18,   products: "aebdgs",   rate: 50 }, {   date: "11-12-2015",   name: "jan",   age: 24,   products: "Żdgs",   rate: 50 }, {   date: "11-12-2015",   name: "tomasz",   age: 50,   products: "fdgs",   rate: 500 }, {   date: "12-11-2015",   name: "Łukasz",   age: 54,   products: "Łbdgs",   rate: 110 }]; 

using lodash's sortbyorder function var ordered = _.sortbyorder(notordered, keys, directions) takes care of sorting using provided keys , directions - 1 after another. , works great. need use provided alphabet order instead of default 1 , make comparisons case-insensitive.

all chars not listed in provided alphabet should compared default way. cannot use localcompare, because need support old ie , mobile browsers.

the question is: can somehow make lodash's sortbyorder function use custom alphabet , if so, how it?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -