This is a follow-up to my "Multisort via Composition" post, and won't make sense if you haven't read that post.
When sorting on a single dimension, changing the sort direction can usually be handled by changing the sorter function directly.
const data = [33, 1, 95, 77, 54, 91, 38, 89, 48, 24];
// ascending
data.sort((a, b) => a - b);
// descending
data.sort((a, b) => b - a);
making this act dynamically based on some external input can be reasonably handled by updating the function as well:
const ascending = getAscending(); // true or false
data.sort((a, b) => (ascending ? a - b : b - a));
This works fine for a single sorter, but quickly becomes untenable once multiple sorting dimensions are used: