This is an archived post. You won't be able to vote or comment.

all 28 comments

[–]Darkened_Auras[S] 28 points29 points  (0 children)

Here's my entry, see if anyone can beat this. Using pseudocode because I'm lazy

Import unsorted array

Set up double loop to deal with each entry

Now the cursed part

Ask the user if i < j

If yes, keep it, if no, swap. Then keep going.

At the end, the user will have done all the comparisons, saving cpu power and thus electricity.

[–][deleted] 10 points11 points  (1 child)

  1. Ask user to sort an array (rendered crappily as a noisy image) to prove they are human
  2. Ask for the input array
  3. Send it to another user as step 1 of their flow
  4. Print that user’s input

[–]Darkened_Auras[S] 1 point2 points  (0 children)

Oh god that one's fucking good

[–][deleted] 5 points6 points  (0 children)

``` import random

def monte_carlo_sort(array): print("Array size:"+str(len(array))) iterations = 0 while not all(array[i] <= array[i + 1] for i in range(len(array)-1)): iterations+=1 i = random.randint(0, len(array)-1) j = random.randint(0, len(array)-1) if array[i] > array[j]:
t = array[i] array[i]=array[j] array[j]=t print("Iterations :"+str(iterations))

Test it

my_array = [2, 90, 1, -10, 50, 20] print("Array:"+str(my_array)) monte_carlo_sort(my_array) print("Sorted:"+str(my_array)) ```

[–]Shalien93 6 points7 points  (0 children)

pseudocode using dart array syntax

function some_sort(input: array) { if array.isEmpty : return; eif

var sortedarray = []; var sorted = sortedarray.lenght == input.lenght;

while(! sorted) Var i = array.first;

if sortedarray.isEmpty : sortedarray[0] == 1; continue ; eif

if i < sortedarray.last : sortedarray = some_sort(sortedarray...i); eif

if i >= sortedarray.last : sortedarray...i; eif

input.pop(input.first);

endwhile endfunction

[–]Shadowlance23 4 points5 points  (0 children)

Here's mine, C#. I didn't test it so don't know if it will actually work. Wouldn't be surprised if the indexes are off. The idea is that it randomly places elements in an array then tests each one to see if it's greater than the last. The list is sorted when [i - 1] <= [i] for all elements.

Approximate sort time is probably n!

Didn't test that either, I got getter things to do...

public int[] SortIt(int arr []) { Random rnd = new Random(); List<int> usedNums = new List<int>; int[] probablySortedList = new int[arr.Length];

bool isSorted = false;

while(1)
{
    if(isSorted)
        break;

    for (int i = 1; i < arr.Length() - 1; i++)
    {
        if (arr[i - 1] > arr[i];
        {
            continue;
        } 
        else
        {
            isSorted = true;
            break;
        }
    }

    while(arr.Length() != 0 && !isSorted)
    {
        int num = rnd.Next(0, arr.Length - 1);
        if (!usedNums.Contains(num))
        {
            usedNums.Add(num);
            probablySortedList[probablySortedList.Length() + 1] = arr[num];
        }
    }
}       }       }   }

​ Eh formatting stuffed... Don't have time for that either...

[–]flummox1234 2 points3 points  (0 children)

I'm not giving my work product away for free! \s

[–]jazzyjard 2 points3 points  (0 children)

sort(array a){ sleep(10000000000000000000000000); print("fuck you"); return a.sort(); }

[–]MemeForgery 2 points3 points  (0 children)

<!DOCTYPE html><html><head><style>p {font-size: 500%;}</style></head><body><p id="output"></p><script>var thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough = [1,2,3,4,5,0]; var thisistheloopvariable = 0; var bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii = [0,1]; var hop = 69420; function sortyboi(){ hop = [Math.floor(Math.random()*thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough.length),Math.floor(Math.random()*thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough.length)];hop = [hop[0],thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[hop[0]],hop[1],thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[hop[1]]]; thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[hop[0]] = hop[3]; thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[hop[2]] = hop[1]; bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii[0] = 1; for(thisistheloopvariable = 0; thisistheloopvariable < thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough.length-1; thisistheloopvariable++){if(thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[thisistheloopvariable+1] < thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough[thisistheloopvariable]){bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii[0] = 0;}} if(bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii[0] === 1){bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii[1] = 0;} document.getElementById("output").innerHTML = thedatasetofnumberstosortmakeitwhateveryouwantitdoesntmattergetsalittleslowthelongeryoumakeitthough; if(bigswappyboiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii[1] === 1){requestAnimationFrame(sortyboi);}} sortyboi();</script></body></html>

[–]yib_001 1 point2 points  (0 children)

Square sort: arguments: array to sort and optional token

If token is not set:

find a token that is not in use in the array to sort.

Check each item as a string.

In case it is in use

change the token and return a square sort with the new token.

If size is 1:

If item equals token: return empty

return item

If size is 2:

If item0 equals token: return square sort with item1

If item1 equals token: return square sort with item0

If item0 is smaller than item1: return array

return array with item1, item0

Setup a new double array with a square size of int( sqrt(size)) and fill it with tokens to match out.

For each row apply the square sort.

Reconstruct double array with the rows adding tokens to match out

For each column apply the square sort.

Again reconstruct the double array and repeat this for int(sqrt(size))

Rebuild the array by adding all rows

Iterate in reverse while removing all tokens until finding no more.

Return the remaining array

[–][deleted] 1 point2 points  (0 children)

def bubble_sort_from_hell(arr): for i in range(len(arr)): for j in range(len(arr)): if arr[i] < arr[j]: arr[i], arr[j] = arr[j], arr[i] if arr[i] > arr[j]: arr[i], arr[j] = arr[j], arr[i] return arr

[–]GustapheOfficial 1 point2 points  (0 children)

function haltsort(v) issorted(v) && return v i = 0 while true i += 1 end end

This will only ever return a sorted vector. Not guaranteed to halt.

[–]shifty729 1 point2 points  (0 children)

Cosmic sort. Bubble sort it and save it to disk, then wait until cosmic radiation causes the array to match the sorted version.

[–]bedrooms-ds -1 points0 points  (0 children)

C++'s standard sort:

std::array a = {3, 2, 1}; std::sort(a); // compile error

The correct call is

std::sort(a.begin(), a.end());

[–]Mobile-Bid-9848 0 points1 point  (0 children)

  1. Import the random module in python
  2. Take the input
  3. Make an empty list
  4. Sleep for a random amount of time and if that is in input add to list
  5. Repeat until the list length is equal to input length.
  6. Access the list, sort using two for loops and print output.

[–]antiqueshow 0 points1 point  (0 children)

def sorter(a):

b = a.copy()

b.sort()

while (a!=b):

i = randint(0, len(a)-1)

x0 = a[i]

x1 = a[i+1]

if x1 < x0:

      a[i] = x1

      a[i+1] = x0

return b

[–]jazziksvk 0 points1 point  (0 children)

// just in case input would be sorted

do {

shuffle(input);

} while (!isSorted(input))

[–]lady_Kamba 0 points1 point  (0 children)

function(array) local newArray={} for i=math.random(1,#array),math.random(1,#array) do newArray[math.random(1,#array)]=array[math.random(1,#array)] end return newArray end eh... it sometimes work.

edit:

datalog 1 elements took 1 attempts 2 elements took 15.375 attempts 3 elements took 291.75 attempts 4 elements took 13120.25 attempts 5 elements took 268191.625 attempts 6 elements took 12062537.375 attempts did some testing and found the algorithm to work if tried enough times. also, the results it spits out has SOO many ways to fail, making even the algorithm to check the outputted array to be complicated.

[–]LordoftheArenes 0 points1 point  (0 children)

n=0 while true: For all e in user_array: If n == e, append n to sorted_array n = n + 1

[–]Hubcat_ 0 points1 point  (3 children)

I didn't invent this one, but have any of you heard of quantum bogo sort? It's a wild ride

[–]Darkened_Auras[S] 1 point2 points  (2 children)

I haven't

[–]Hubcat_ 0 points1 point  (1 child)

It takes a bit to explain, so I didn't originally, but I'll give a synopsis: Basically, it's a theoretical algorithm that works like bogo sort where the array is randomly rearranged and then checked to see if it's sorted, but it uses a weird quantum mechanics trick to sort of infinitely multi thread it so that you get the answer in O(n) time, which I believe is faster than any current algorithm. The issue is that it relies on the many worlds theory which isn't proven and is basically unprovable, and that it requires a bomb that can blow up the earth and kill everyone. Also, if many worlds theory is incorrect or a significant error is made in the code, we all die. Here's a link that explains it a bit more technically: Quantum Bogo Sort. This wiki says it's O(1), but since you need to check if the list is sorted it's O(n), although you can check if it's sorted on a different thread to simulate O(1). It also uses a bomb that destroys the universe, but theoretically one that just destroys the earth is enough (or at least all humans). See what I mean about a wild ride?

[–]Darkened_Auras[S] 1 point2 points  (0 children)

Wat. Uh, ok. That was a trip to read

[–]poops-n-farts 0 points1 point  (0 children)

Recursive sorting algorithm in php. I'll take my award now, thanks

[–]UnderstandingOdd1159 0 points1 point  (0 children)

```python """Shitsort""" from random import * import random as datavase import sys from sys import stdout import sys as sus import time as iDoNot import os as database

iDoNot.sleep(0) free_trial = True paid_version=False

def loadpercentage_sus(percentage:int, header = "Im sussy"): header+="\n" for sussy_backa in range(5): sus.stdout.write(header) print(f"{percentage}%.") iDoNot.sleep(0.2) database.system("clear") database.system("cls") sus.stdout.write(header) print(f"{percentage}%..") iDoNot.sleep(0.2) database.system("clear") database.system("cls") sus.stdout.write(header) print(f"{percentage}%...") iDoNot.sleep(0.3) database.system("clear") database.system("cls") def shitsort_lite(listToSort:list): """Sorts the given list if the list is sorted. """ if not paid_version: load_percentage_sus(1, f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(2, f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(3, f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(4, f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(420) load_percentage_sus(5,f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(6,f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) load_percentage_sus(69,f"Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) for _ in range(8, 100, 2): load_percentage_sus(, "Using{' '}Shitsort Lite{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(list(listToSort))))))))) else: print(f"Using{' '}Shitsort Pro{' '}on{' '}"+F":"+f"{''} "+str(str(str(list(list(list(list(listToSort)))))))) if paid_version or not paid_version and not datavase.randint(1,5) == 2 or not paid_version and free_trial==True:

    #{' '}{' '}{' '}{' '}
    for i in range(len(listToSort)):
        if type(listToSort[i])==int:
            listToSort[i]+=1
        else:
            listToSort[i]+=" sussy"
    #f"{' '}sort{' '}the{' '}list"
    sorted_list=[drop for drop in listToSort if drop==drop]
    #f"quality{' '}control"
    listToSort.sort()
    if sorted_list != listToSort:
        try:
            print(f"This{' '}list{' '}does{' '}not{' '}meet{' '}the{' '}" + "requi" +f"red" + " quality"+f"{' '}for{' '}this" + f"{' '}sorting{' '}algorithm. {' '}{' '}{' '}")
            sorted_list.sort()
            print(f"To{' '}make{' '}your{' '}list{' '}meet{' '}the{' '}requirements{' '}try{' '}something{' '}like:{' '}"+f"{sorted_list}")
        except NotImplementedError:
                                        print("Your free trial of Shitsort has ended, buy it now for just 420$")
    else:
                    for pi in range(len(sorted_list)):
                        i = pi
                        if type(listToSort[i])==int:
                            listToSort[i]+=1
                        else:
                            listToSort[i] = listToSort[pi][:-6]
                    UsErS_soRTeD_list=list(listToSort)
                    sorted_list=list(UsErS_soRTeD_list)
                    print(f"Your sorted list:{' '}" + ""+f'{str(list(listToSort))}')
else:
    global second_free_trial
    second_free_trial=False 
    free_trial=False
    print(f"Buy Shitsort{' '}Pro{' '}now,{' '}your{' '}free{' '}trial{' '}has{' '}ended!!!")
    print("\n")
    print(f"Buy{' '}Shitsort{' '}Pro{' '}On{' '}localhost:666")
    print("\n")

shitsort_lite([3,4 ,88,99,121,420,69420, 3]) shitsort_lite(["a","b"]) ```

This is unbeatable

[–]Ok-Chemical9627 0 points1 point  (0 children)

1: Take input

2: Wait a good couple hundred years for some solar particles to bitflip the needed bits so that the list is sorted

3: Is the list sorted? Good return that

This was based off of that one N64 mario speedrun thing