JavaScript
Sort lines lexicographically ascending

by Benny Neugebauer

const names = ['Ralf', 'Berta', 'Arnold', 'Zusan', 'Susan'];

names.sort((a, b) => {
  if (a < b) return -1;
  if (a > b) return 1;
  return 0;
});

// ["Arnold", "Berta", "Ralf", "Susan", "Zusan"]

const names = ['Ralf', 'Berta', 'Arnold', 'Zusan', 'Susan'];

names.sort((a,b) => a.localeCompare(b));

// ["Arnold", "Berta", "Ralf", "Susan", "Zusan"]