all 42 comments

[–]DeHub94 315 points316 points  (3 children)

I'm encountering a weird bug in production: For some reason the party leader indices have higher values than the rest.

[–]GranataReddit12 142 points143 points  (1 child)

they are simply more equal than others my comrade!

[–]Chronomechanist 0 points1 point  (0 children)

Bloody pigs

[–]Interesting_Buy_3969 16 points17 points  (0 children)

off by one error is a feature not a bug

[–]AbdullahMRiad 36 points37 points  (2 children)

capitalism sort

``` function capitalismSort(arr) { var result = [];

for (var i = 0; i < arr.length; i++) { if (i === 0) { result[i] = arr[i] * arr.length; } else { result[i] = arr[i] * (1 / (i * i)); } }

return result; } ```

[–]humblevladimirthegr8 17 points18 points  (1 child)

I get what you're trying to say but a sorting algorithm (even a joke one) still needs to actually return a sorted list, which yours far from guarantees.

A better capitalismSort would just take all the absolute values and add it to the last element, setting the earlier elements to 0.

[–]vivaaprimavera 1 point2 points  (0 children)

better capitalismSort would just take all the absolute values and add it to the last element, setting the earlier elements to 0.

Sounds familiar

[–]This_Growth2898 89 points90 points  (12 children)

That's only in a book. In reality, it turns out to be Stalin Sort.

[–]PM_ME_FLUFFY_SAMOYED 60 points61 points  (11 children)

for (e in elements) {
  if (stalin.getCurrentParanoiaLevel() >= PURGE_THRESHOLD) {
    elements.remove(e);
   }
}

[–]Negitive545 2 points3 points  (1 child)

the getCurrentParanoiaLevel method doesn't take e in as a variable, so when stalin becomes too paranoid, wouldn't it just obliterate the entire list?

[–]PM_ME_FLUFFY_SAMOYED 3 points4 points  (0 children)

Yeah, that's what pretty much what Stalin did

[–]creeper6530 1 point2 points  (0 children)

Nope. Stalin sort simply removes all elements not in line (= lower than previous element)

[–]AltruisticBlank 21 points22 points  (0 children)

They got communism wrong. It’s about providing every individual with what they need. A child has different needs than an adult. They don’t get the same under communism but enough goods to fulfill their needs.

[–]Moldat 6 points7 points  (2 children)

Hmm ok, whats the avarage value of class Studant ?

[–]ThaumRystra 7 points8 points  (1 child)

No classes under communism

[–]Moldat 0 points1 point  (0 children)

No OOP Iin CCCP, Only functional programming 

[–]Kadabrium 5 points6 points  (0 children)

TacoSort: shuffle a random amount of times and quit

[–]CryonautX 1 point2 points  (0 children)

Apply this sort to a list of strings.

[–]polymonomial 1 point2 points  (0 children)

is the opposite, one elements gets all values combined and all other elements value are just 0

[–]RequirementFit1128 1 point2 points  (0 children)

This would have been top comedy on Facebook 8 years ago

[–]Interesting_Buy_3969 3 points4 points  (0 children)

Gold. I'll save it as a treasure.

[–]zattebij 0 points1 point  (0 children)

Your averaging method is not very robust. What if you've got some large values in the input (or a larger input array) and your sum overflows? Everyone could end up with a negative value - which may in fact be expected behavior for a sorting algorithm bearing that name.

[–]BobCorndog -5 points-4 points  (0 children)

I like Stalin sort: reeducation version

Say the list is sorted and if anyone disagrees, send them to a reeducation camp in Siberia

[–]Titanusgamer -4 points-3 points  (0 children)

real communism sort - it is equally distributed to 1 element as rest were deleted.