American Flag Sort

An american flag sort is an efficient, in-place variant of radix sort that distributes items into hundreds of buckets. Non-comparative sorting algorithms such as radix sort and american flag sort are typically used to sort large objects such as strings, for which comparison is not a unit-time operation.

American flag sort iterates through the bits of the objects, considering several bits of each object at a time. For each set of bits, american flag sort makes two passes through the array of objects: first to count the number of objects that will fall in each bin, and second to place each object in its bucket. This works especially well when sorting a byte at a time, using 256 buckets. With some optimizations, it is twice as fast as quicksort for large sets of strings.

The name comes by analogy with the Dutch national flag problem in the last step: efficiently partition the array into many "stripes".

Read more about American Flag Sort:  Algorithm, Sample Implementation in Python

Famous quotes containing the words american, flag and/or sort:

    Those who sit in a glass house do wrong to throw stones about them; besides, the American glass house is rather thin, it will break easily, and the interior is anything but a gainly sight.
    Emma Goldman (1869–1940)

    My dream is that as the years go by and the world knows more and more of America, it ... will turn to America for those moral inspirations that lie at the basis of all freedom ... that America will come into the full light of the day when all shall know that she puts human rights above all other rights, and that her flag is the flag not only of America but of humanity.
    Woodrow Wilson (1856–1924)

    Who will join in the march to the Rocky Mountains with me, a sort of high-pressure-double-cylinder-go-it-ahead-forty-wildcats- tearin’ sort of a feller?... Git out of this warming-pan, ye holly-hocks, and go out to the West where you may be seen.
    —Administration in the State of Miss, U.S. public relief program (1935-1943)