Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal eglamkowski's Journal: RandomSort() 10

For those who are still wondering, what this function does is it takes a list of names that are sorted alphabetically, assigns a random number to each one, then sorts the numbers so that the names appear to be random.

If I had written it I probably would have called it RandomizeList or RandomizeNames or some such, but no, this person had to call it RandomSort.

*rolls eyes*

This discussion has been archived. No new comments can be posted.

RandomSort()

Comments Filter:
  • It's the only way they'll learn. ;)
    • So I don't get me legs broken...

      Is the issue with Random since computer generated randomness isn't technically random, or is it that its uses Sort instead of the more specific Name?

      Or, likeliest of all, am I going to get me legs broken for missing the issue entirely?

      • The bone I pick with the function name, is that when I see "Sort" in a function name, I expect the result to be in a consistent, reproducible, order. Whether it's ascending, descending, by date, alphabetically, whatever.

        Wow, that's the second time today that Firefox has crashed while typing in a post.

        Back on topic: A better function name would have been RandomizeList as eglamkowski suggested. Or even "ScrambleList". Sort has a meaning to us CSE types.

        Your legs are safe, the developer who wrote that f
        • by nizo ( 81281 ) *
          This seems like a good time to mention what I always tell people when this kind of thing comes up: Yeah they are in order, it just so happens they are in random order :-)
          • THAT DOES IT!!

            This is going to hurt you more that it's going to hurt me.

            WHOOOO!!! TO BE THE MAN, YOU'VE GOT TO BEAT ME MAN! WHOOOO!!

            /me applies Figure-Four Leglock

            WHOOOO!! WHOOOOO!!

            ;)
          • You're joking, but I was thinking seriously along the same lines:

            Looking at sorting more generically, it's just a particular criterion for (re-)ordering a list of items. The abstraction is reordering, and the order is the specific. So in this code I would've made functions ReorderSorted() and ReorderRandom().
  • Is there a political purpose to do this? Perhaps a randomly assigned task?

    However, given your description, RandomSort makes sense of the name- in a rather assinine way. After all, first it randomizes, then it sorts. Two separate functions in one, and the name perfectly describes those two functions. The assinine part is that it doesn't explain the structure it's doing this to- not very good self-referencing code.
    • It does this for regulatory reasons, actually. The names are of companies and they don't want there to be any assinine preference for one company over another, and if the same company is always at the top of the list, because it's sorted alphabetically for example, the concern is that company will be selected in almost all cases just on account of ease, that is to say, of sheer laziness on the part of the user.

      Of course, if you do have a specific company you want, the random order makes it a bitch to find,
      • by RevMike ( 632002 )
        Why not alphabetize the list, then choose a random default?
        • I have no idea - the people who wrote a lot of this code originally weren't all the very brightest. Not sure who wrote this specific function, but...

Congratulations! You are the one-millionth user to log into our system. If there's anything special we can do for you, anything at all, don't hesitate to ask!

Working...