[Javascript] Array sort - keep one item always last
For example, we have a dropdown list, we want to keep "other" option always as last option.
return options .sort((a, b) => { if (a.value == b.value) return 0; if (a.value == 'other') return 1; if (b.value == 'other') return -1; return a.value.localeCompare(b.value); });