Questions tagged [sorting]

This challenge is intended to be solved by sorting, ordering, or otherwise organizing some set of data.

2
votes
2answers
208 views

Merging text files based on a prefix key

Imagine an ordered file set : file1, file2, ... fileN. Each file is a textual file that is ...
35
votes
69answers
14k views

Sort numbers by binary 1's count

Goal Write a function or program sort an array of integers in descending order by the number of 1's present in their binary representation. No secondary sort condition is necessary. Example sorted ...
2
votes
13answers
2k views

Sort an array only using recursion

Your task is to write a function that sorts an array. Your function: Cannot call other functions (excluding itself, of course); Must receive an array of integers as input, and it must return the ...
13
votes
38answers
4k views

Shortest Program to Sort a List of numbers into Odd and Even Category

In the New Modern Times, when Charlie Chaplin encounters a computer, he is employed in the sorting Yard, as a validator to determine if the workers are correctly sorting the items. The Items in ...
12
votes
23answers
15k views

Sorting a list of strings without using any built-in sort method

The goal of this Code Golf is to create a program that sorts a list of strings (in ascending order), without using any built-in sort method (such as Array.Sort() in ...
28
votes
12answers
4k views

Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...
4
votes
2answers
380 views

Pseudosort a list in 2*n comparisons

Write a program that takes a list of n space-separated integers, and outputs a permutation of that list using a maximum of 2*n comparisons. It should loop this until an empty line is input. ...
18
votes
14answers
1k views

The Strange Unsorting Machine for Nefarious Purposes

Good Evening Golfers! Your challenge is to completely unsort a series of numbers. Input Exactly 100 integers will be fed to your program. Your program may accept the input either as a file, or via ...
16
votes
15answers
1k views

City names game

If you like, write a program which sorts cities according to the rules of city name game. Each name of the city should start from the last letter in the previous city name. E.g. ...
-6
votes
14answers
777 views

Sort, with your hands tied behind your back [closed]

The problem is very simple: write a program that accepts a single unsigned integer from the command line, and prints out that many random numbers on the standard output, in ascending order. For ...
16
votes
6answers
857 views

Code Golf: Mix the nuts so that none of the same kind are touching

Input: Input is a randomized array of nuts (in your language), the possible nuts follow. Your program must have a way of representing each kind of nut, such as an integer code. Program must be able ...
-8
votes
1answer
417 views

Sort an array with values of integer [closed]

There is an array of integer values to be sorted.During the sorting process, the places of two numbers can be interchanged. Each interchange has a cost, which is the sum of the two numbers involved. ...
-5
votes
3answers
5k views

Descending Sort using Standard Ascending Sort Function [closed]

Taking an array of records. For example ...
71
votes
23answers
11k views

Contest: fastest way to sort a big array of Gaussian-distributed data

Following the interest in this question, I thought it would be interesting to make answers a bit more objective and quantitative by proposing a contest. The idea is simple: I have generated a binary ...
32
votes
2answers
5k views

Implement QuickSort in BrainF*** [closed]

As discussed in the Lounge room on Stack Overflow: if you can't implement the Quicksort algorithm given en.wikipedia.org/wiki/Quicksort in any language you have minimal knowledge of, you might want ...
3
votes
1answer
467 views

Fastest alphabetical list sort given the following limitations:

Your function must have an input that takes in an array containing 10000 random names, and must sort these names in alphabetical order. Names have a random length of up to 128 characters. ISO/IEC 8859-...
4
votes
11answers
1k views

Implement a sorting algorithm with no change. [closed]

In this task, you have to write a program, that reads a string with a length of up to 1024 characters and prints it out sorted. In order to make an interesting task from a boring one, I set a few ...
7
votes
0answers
764 views

Stable positive/negative separation [closed]

From SO. You are given an array with positive and negative integers. Write a function to change the elements order in the array such that negative integers are at the beginning, the positive integers ...
25
votes
33answers
7k views

Sort a list of numbers [closed]

About Code-Bowling: In golf, you try to get the lowest score (smallest application, most elegant, etc). In Bowling, you try to get the highest score. So if you follow, the goal of a Code-Bowling ...
28
votes
37answers
2k views

Implement Bogosort

Is solving Sudoku too hard? Even the brute force version? Here's a coding exercise that's a little easier. I hope. :-P Write the shortest function to implement bogosort. In specific, your function ...