Sort lines alphabetically

Sort a list of words or lines of text into alphabetical order. Sorting can be toggled to be case sensitive, and be in either ascending or descending order.

Face with waiting expression Nothing to see yet!

Loading takeymakey...
TakeyMakey code
Want this tool to do something else? Edit the code below and make it do whatever you want.
({
  take: [
    { key: "lines", type: "list", label: "Text" },
    { key: "order", type: "toggle", label: "Sort ascending", value: true },
    { key: "case", type: "toggle", label: "Case sensitive", value: true },
  ],
  make: (data) => {
    const value = (v) => (data.case ? v : v.toLowerCase())
    return data.lines.sort(
      (a, b) => (data.order ? 1 : -1) * (value(a) > value(b) ? 1 : -1)
    )
  },
})