Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Generalized Sort

JavaScript, 25 bytes Arguments are curried, i.e. f(a)(s), where a is the array to be sorted and s is an array of functions to sort by, in reverse order. Modifies a in place, which I don't know tha...

posted 3y ago by Shaggy‭  ·  last activity 3y ago by Shaggy‭

Answer
#3: Post undeleted by user avatar Shaggy‭ · 2021-09-02T10:29:54Z (about 3 years ago)
#2: Post deleted by user avatar Shaggy‭ · 2021-09-02T09:42:23Z (about 3 years ago)
#1: Initial revision by user avatar Shaggy‭ · 2021-09-02T09:23:08Z (about 3 years ago)
# JavaScript, 25 bytes

Arguments are curried, i.e. `f(a)(s)`, where `a` is the array to be sorted and `s` is an array of functions to sort by, in reverse order. Modifies `a` in place, which I don't know that we have a consensus on here yet - if it's not permitted then add `&&a` to the end to return the sorted array.

<!-- language-all: lang-javascript -->

    a=>s=>s.map(g=>a.sort(g))

[Try it online!](https://tio.run/##fVJbb4IwFH7nV5i@jCZIhr6Z4TKX7MFt@sDDVGJCwQpVBNM2U1z87ayUW2dwCWlyvss5p1/ZoW/EAkqOvJ@kG5xv7RzZYyY@84COemiPkclSyvUQwjxBB8xsF7xGlDBOEtSbplHC0gQYwOH4hOimA/mKCMdKPX@YUIJUhXMgPBL1hMRxUxSNlG7TYnZDOiiOM4VtN/rEGaashtqyntUAcli7ywoFEaJZM6G0T2h6UtlW/@L7uFXXfNNdbl@7y21vtTfbVzmttSLumbitrSPDNwiUT3CMCfd6nkvWT75aPfetkSUtb4QyLj3CUfeQLR6hFHygO7wFta0u3xbqbtPKqD1rqAWp2DTGZpyG@tSZz0zGKUlCss0qH9S01N/hgIvf4wecwcgyQAZGAwNcxHk1JDZUsGGFDTqw0mvd1Vl/dPex4bUM8x1nZZb7Ikt3LyIUR5vcQk1FiKXWO3tlbMtONqvYVSd78YpIq0SqUFcy0KU8F/9nWhth/gs)