I have array and contains 50 values ,
example
[
'london',
'bluehit',
'green',
'lonpark',
'abc',
'aab',
'lonsee',
]
I want to sort with preference given to values starting with a provided string, then traditional alphabetical sorting.
If I give an argument as lon then my array should be sorted as:
[
'london',
'lonpark',
'lonsee',
'aab',
'abc',
'blurhit',
'green',
]
this is it 😉
upd: even simpler is to prepend the string with “\x01” rather than replacing it. This also allows for case-insensitive matching or to match a set of strings: