skip to Main Content

Javascript – sorting an array with unique scenario

I have a problem with sorting arrays in javascript: My original array: let orginalArray = ["Apple","apple","Acrobat","Account","account","Banana","banana","carrot","Carrot",1,2]; Looking for an output like this: sortedArray = ["Account","Acrobat","Apple","account","apple","Banana","banana","Carrot","carrot",1,2]; This is what I tried: let sortedArray = orginalArray; sortedArray.sort((a, b) => a[keyname].toString().localeCompare(b[keyname].toString(),'en', { caseFirst:…

VIEW QUESTION
Back To Top
Search