There’s an array of structures
struct
{
string name;
string 2nd_name;
int age; // 0 to 150
}
Maximum array’s length is 10^8.
I know I could use mergesort/quicksort and all the others well known algorithms, however I’d like to know if It’s possible to add something else that would speed up the sorting.
People’s age is somewhat different than arbitrary integers for sorting: it has a very small number of possible distinct values (all people’s ages are between 0 and 150). So the quickest way to sort it would be to allocate 151 linked lists (let’s call them buckets) and put each person’s data structure in the bucket according to his/her age: