Tacto Demo

The sorter in this page takes a list of Person objects. Each person contains:

The sorter first sorts each Person by their favorite color according to how light/dark the color is, then they are sorted chronologically by their birthdays, next they are sorted by a custom comparison function that evaluates the name of the country, and lastly alphabetically by their name. The sort is not very practical, but it shows the flexibility of the library. Below is what the main sorter composition looks like.

const sorter = tacto<Person>(
  tacto.sorters.asc(({ favoriteColor }) => rgbToLightness(favoriteColor)),
  tacto.sorters.asc(({ birthday }) => new Date(birthday)),
  tacto.sorters.raw(comparePersonCountry),
  tacto.sorters.asc(({ name }) => name)
);