For example, we have a dropdown list, we want to keep "other" option always as last option.

         returnoptions
                .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);
                });            

 

相关文章: