Forgot your password?
typodupeerror
Math

Ask Slashdot: How Do You Sort? 195

Posted by Soulskill
from the sort-of-slowly dept.
camperdave writes "I was recently going through a pile of receipts and other papers to put them into order by date. Lacking one of those fancy sorting sticks they have at the office, I wound up with all sorts of piles and I was getting confused as to which pile was for what. Finally, it struck me: Why don't I use one of the many sorting algorithms I learned back in my computer science classes? So I swept all the papers back into the box and did a radix sort on them. It worked like a charm. Since then, I've had occasion to try quicksorts and merge sorts. So, when you have to physically sort things, what algorithm (if any) do you use?"
This discussion has been archived. No new comments can be posted.

Ask Slashdot: How Do You Sort?

Comments Filter:
  • by kebes (861706) on Saturday March 01, 2014 @05:29PM (#46378157) Journal
    Human sorting tends to be rather ad-hoc, and this isn't necessarily a bad thing. Yes, if someone is sorting a large number of objects/papers according to a simple criterion, then they are likely to be implementing a version of some sort of formal searching algorithm... But one of the interesting things about a human sorting things is that they can, and do, leverage some of their intellect to improve the sorting. Examples:
    1. Change sorting algorithm partway through, or use different algorithms on different subsets of the task. E.g. if you are sorting documents in a random order and suddenly notice a run that are all roughly in order, you'll intuitively switch to a different algorithm for that bunch. In fact, humans very often sub-divide the problem at large into stacks, and sub-sort each stack using a different algorithm, before finally combining the result. This is also relevant since sometimes you actually need to change your sorting target halfway through a sort (when you discover a new category of document/item; or when you realize that a different sorting order will ultimately be more useful for the high-level purpose you're trying to achieve; ...).
    2. Pattern matching. Humans are good at discerning patterns. So we may notice that the documents are not really random, but have some inherent order (e.g. the stack is somewhat temporally ordered, but items for each given day are reversed or semi-random). We can exploit this to minimizing the sorting effort.
    3. Memory. Even though humans can't juggle too many different items in their head at once, we're smart enough that we encounter an item, we can recall having seen similar items. Our visual memory also allows us to home-in on the right part of a semi-sorted stack in order to group like items.

    The end result is a sort that is rather non-deterministic, but ultimately successful. It isn't necessarily optimal for the given problem space, but conversely their human intellect is allowing them to generate lots of shortcuts during the sorting problem. (By which I mean, a machine limited to paper-pushing at human speed, but implementing a single formal algorithm, would take longer to finish the sort... Of course in reality mechanized/computerized sorting is faster because each machine operation is faster than the human equivalent.)
  • Two-pass bucket sort (Score:4, Interesting)

    by JazzHarper (745403) on Saturday March 01, 2014 @05:42PM (#46378223) Journal

    First by rank (13 buckets) then by suit (4 buckets). I can typically sort a well-shuffled deck of bridge cards in about 85 seconds. That's far from the world record, but significantly faster than most people can do.

  • Re:GPUs (Score:4, Interesting)

    by mikael (484) on Saturday March 01, 2014 @06:17PM (#46378343)

    Yes, they are called compute shaders. There are several parallel algorithm, of of which is called the bitonic sort.

    http://en.wikipedia.org/wiki/B... [wikipedia.org]

    You just load all your data into GPU memory, with one data element per thread, then at each stage, use one thread to compare pairs of data.
    There's a very specific pattern which is specified by this web page.

The biggest mistake you can make is to believe that you are working for someone else.

Working...