Questions tagged [sorting]
This challenge is intended to be solved by sorting, ordering, or otherwise organizing some set of data.
214
questions
9
votes
8
answers
1k
views
Sort Number Array
Given array \$A\$ \$(a_0, a_1,... , a_n) \$ as a permutation of \$(0, 1,...,n)\$ where \$n ≥ 2\$. Sort array \$A\$ into array \$(0, 1,...,n\$) with \$2\$ caveats:
\$1\$ swap is counted when swapping ...
8
votes
3
answers
448
views
Stably sort N elements in this restricted "cmov" language
The following problem is taken from the real world — but indubitably code-golf!
In this puzzle, the programming language is fixed, and your job is to write the most ...
20
votes
32
answers
3k
views
Iteratively sort a list
Given a list of Integers greater than zero, Sort each of the unique values in ascending order, then repeat the process on the remaining duplicate values and append.
Example:
...
4
votes
6
answers
282
views
Pseudo-Quantum Bogosort [closed]
Pseudo-Quantum Bogosort
Quantum Bogosort is as follows:
Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the ...
15
votes
17
answers
2k
views
How long to carry sort?
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest ...
19
votes
19
answers
1k
views
"Sort" by element duplication
Inspired by one of many bugs I ran into while implementing selection sort in trilangle.
Given a non-empty list of non-negative integers, "sort" the list using the following procedure:
Find ...
14
votes
8
answers
2k
views
Change the subject
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the ...
14
votes
10
answers
422
views
CGAC2022 Day 17: Present Heap
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Inspired by https://xkcd.com/835
In the midst of his mid-life crisis, Santa has impulsively purchased a Sports ...
13
votes
14
answers
1k
views
CGAC2022 Day 10: Help Santa sort presents!
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Santa likes to sort his presents in a special way. He keeps "uninterleaving" the pile of presents into ...
26
votes
7
answers
3k
views
Fix my FizzBuzz
FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz&...
1
vote
1
answer
262
views
Implement the slowest possible sorting algorithm that retains a fast best case [closed]
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best.
The task is simple: Sort an array of integers in as long average time as ...
5
votes
0
answers
257
views
Sort my Cups︎︎︎︎︎︎︎︎︎︎ [closed]
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any ...
13
votes
9
answers
2k
views
Magic: the Gathering - Colour Sorting
Related: Deck Names Friends or Foes Paying for Spells
The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of ...
9
votes
2
answers
357
views
Sorting passengers on a plane
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it.
I will briefly summarise the puzzle here....
21
votes
14
answers
2k
views
Sort numbers in a ragged list
Given a ragged list, e.g.
[[4, 7], [5, 3, [], [6, [2]]]]
Your challenge is to sort only the numbers in it. For example, with the above, the result would be
...