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:

    Speed is scarcely the noblest virtue of graphic composition, but it has its curious rewards. There is a sense of getting somewhere fast, which satisfies a native American urge.
    James Thurber (1894–1961)

    Up rose old Barbara Frietchie then,
    Bowed with her fourscore years and ten;

    Bravest of all in Frederick town,
    She took up the flag the men hauled down;
    John Greenleaf Whittier (1807–1892)

    I am opposed to writing about the private lives of living authors and psychoanalyzing them while they are alive. Criticism is getting all mixed up with a combination of the Junior F.B.I.- men, discards from Freud and Jung and a sort of Columnist peep- hole and missing laundry list school.... Every young English professor sees gold in them dirty sheets now. Imagine what they can do with the soiled sheets of four legal beds by the same writer and you can see why their tongues are slavering.
    Ernest Hemingway (1899–1961)