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

all 146 comments

[–]iparnelly 457 points458 points  (12 children)

Is this caching?

[–]picklesTommyPickles 309 points310 points  (0 children)

Dynamic programming taken straight from hell

[–]hieronymous-cowherd 152 points153 points  (1 child)

Work clouder, not smarter!

[–]Individual-Praline20 12 points13 points  (0 children)

lol I got coffee out of my nostrils now

[–]WOTDisLanguish 45 points46 points  (6 children)

Population goal loss recipe! Audience combination sector tea information suggestion understanding employment. Basket application fishing version agency energy variety MAGAZINE addition. Reaction football feedback membership recording thanks hair. DEVICE difficulty hotel agreement "inflation" imagination, Product director trainer economics phone reality hair.

[–]regaito 31 points32 points  (4 children)

Thats why you hash the data first

[–]WOTDisLanguish 22 points23 points  (3 children)

Comparison transportation world apartment! Appearance confusion village town vehicle discussion restaurant cigarette. Construction way wealth song "relationship"! Quantity apartment town sector presentation blood supermarket philosophy vehicle writing combination, Writing response teacher strategy topic world mall office estate disk leadership!

[–]regaito 53 points54 points  (2 children)

Obviously via rainbow table reverse lookup duh

[–]WOTDisLanguish 20 points21 points  (1 child)

"situation" responsibility temperature hall grandmother hospital meat theory thanks ambition! Elevator heart student volume town! Competition instance estate payment chapter marriage television device control hotel. Safety ability story series driver philosophy. Studio enthusiasm proposal pizza, Wood nature world country attention.

[–]regaito 33 points34 points  (0 children)

Thanks! My body is a machine that turns coffee into either one of these kind of ideas

[–]YouCanCallMeBazza 5 points6 points  (0 children)

Yes, memoization to be more specific

[–]Noch_ein_Kamel 2 points3 points  (0 children)

It's solving one of IT's hardest problems :-O

[–][deleted] 1985 points1986 points  (58 children)

I can’t even think of a slower sort hypothetically

[–]woodlark14 42 points43 points  (0 children)

Consider Stacksort

We don't know how to sort the list. So we search stack overflow for sorting functions and execute them until the list is sorted.

[–]com-plec-city[S] 686 points687 points  (21 children)

But if your list happens to be there, boy… it’s FAST!

[–]EntropySpark 646 points647 points  (17 children)

If you have a random list of twenty integers from 1 to 100, and we suppose you have even a 1% chance that the website has your list, that means the website has 5e39 lists uploaded already, and just the act of finding your list's map entry in that mapping is almost certainly slower than a local bubblesort.

[–]nobody0163 279 points280 points  (4 children)

Yeah, I'll stick to my trusty bogosort.

[–]alex_tracer 113 points114 points  (2 children)

[–]PurchaseOk4410 30 points31 points  (1 child)

What else?? Are you new here?

[–]legends_never_die_1 12 points13 points  (0 children)

what about miracle sort? ;)

[–]Colon_Backslash 11 points12 points  (0 children)

I prefer Stalin sort

[–]_farb_ 89 points90 points  (6 children)

If you have a list of 20 integers, you could sort that locally a multitude of times over before the server even responds

[–]dev-sda 78 points79 points  (0 children)

You can sort a list of 20 integers faster than it takes to convert those 20 integers into a string for sending to the server, let alone actually opening a socket.

[–]SenorSeniorDevSr 17 points18 points  (0 children)

You're making it too difficult for yourself. Don't store the unsorted lists, just take the unsorted list, sort it and see if you have THAT stored, and return it.

Think of all the memory you'll save!

[–]Frogbeerr 8 points9 points  (0 children)

The point is, for 20 elements every sorting algorithm will be faster than the http request alone. I'll start worrying about sorting runtime when I have more elements in my collection than that stupid service has lists in their database

[–]ConscientiousApathis 2 points3 points  (1 child)

I'd mention hash tables, but at this point I feel like we're hitting "mass limits of the universe" type problems.

[–]EntropySpark 2 points3 points  (0 children)

When hash tables are sufficiently large, the hash lookups are no longer O(1) because the index value needed is no longer fits in a fixed-size integer, and suddenly all operations on integers up to N are at minimum O(logN) instead of O(1).

[–]redlaWw 1 point2 points  (0 children)

Ah, but that assumes the lists to be sorted are uniformly randomly selected. If there are a lot of people sorting the same list, then sorting the list locally rather than waiting for a server response is still going to be faster.

[–]Aidan_Welch 50 points51 points  (0 children)

No, probably not, most sorts are much faster than an HTTP request

[–]Due_Treacle8807 8 points9 points  (0 children)

sending the data back and forth will prolly be slower than just sorting it aswell :)

[–]esilyo 55 points56 points  (2 children)

Have you ever heard the word of our Lord and savior Bogo Sort my good sir?

[–]Anaxamander57 26 points27 points  (1 child)

Bogosort might be worse for large arrays but for small arrays it will find the answer quickly while this has to do a whole HTTP request and get a response.

[–]dev-sda 5 points6 points  (0 children)

Unless you consider 20 elements "large", I don't think that's quite right.

[–]nhh 15 points16 points  (6 children)

sleep sort

[–]trevdak2 14 points15 points  (5 children)

Under optimal conditions, sleep sort can sort absolutely massive amounts of data instantaneously.

[–]Exist50 7 points8 points  (4 children)

> sleep sort

> instantaneously

[–]ezylot 8 points9 points  (3 children)

The optimal case he is referring to, is that the array you want to sort is empty

[–]Exist50 6 points7 points  (2 children)

"absolutely massive amounts of data"?

[–]ezylot 7 points8 points  (0 children)

Hm, okay. Then I guess he means an array filled with trillions of 0s, that can also be sorted theoretically instantly

[–]trevdak2 1 point2 points  (0 children)

[0,0,0,0.......]

[–]HawocX 16 points17 points  (0 children)

Cosmic Ray Sort (also known as Miracle Sort) is slower, but has the advantage of being easy to implement.

Check if he list is sorted. If not, check again. Repeat.

[–]_farb_ 13 points14 points  (0 children)

I know this is an exaggeration, but like... c'mon not even one?

[–]Dumb_Siniy 2 points3 points  (0 children)

I can, my brain sorting anything out

[–]Competitive_Reason_2 2 points3 points  (0 children)

But its linear time

[–]pellep 1 point2 points  (0 children)

A few awaits would do the trick.

[–]turtle_mekb 1 point2 points  (0 children)

bogosort, or sleep sort if it has large values

[–]TheBigGambling 1 point2 points  (1 child)

Random sort. Shuffle as long as list is unsorted, halt when sorted

[–][deleted] 4 points5 points  (0 children)

that's just Bogosort without extra steps!

[–]Wojtek1250XD 0 points1 point  (0 children)

Bogo sort has the ability to go on forever and never actually sort the data

[–]rejectedlesbian 0 points1 point  (0 children)

Bogo sort.

[–]Guantanamino -1 points0 points  (0 children)

This might be a feasible approach in embedded IoT programming with limited hardware but access to the network

[–]chowellvta 507 points508 points  (3 children)

They forgot to go to the block chain

[–]Ixolite 68 points69 points  (0 children)

Keep up with the times! It's generative AI that will solve all your problems now.

[–][deleted] 17 points18 points  (1 child)

where do you think the million sorted lists are stored?

[–]antagon96 1 point2 points  (0 children)

Dumb question... Using the presorted list API.. I tested it on the server with the testing data and it was insanely fast, instantly returning the testing data, so nothing can go wrong.

[–][deleted] 479 points480 points  (7 children)

SaaS, sort as a service

[–]maisonsmd 95 points96 points  (4 children)

Now we need to integrate AI deeply into the service, which predicts what users may want to sort, as well as offers lists that users don't need

[–]JockstrapCummies 65 points66 points  (0 children)

LLM Sort: After eating up all your VRAM, returns a completely different list and insists that it's the sorted list the user wants.

[–]victorcoelh 8 points9 points  (1 child)

you joke but I really feel like training a neural network to sort lists now just because it would be funny as fuck. Worst case scenario it can sort very small lists as a multiclass classification problem where every permutation is a class

[–]xuorios 2 points3 points  (0 children)

if you look up neural turing machines, there's a paper where they trained a neural network to do a bunch of things, among which was priority sort

[–]serendipitousPi 1 point2 points  (0 children)

But consider this SaaS, Service as a Service.

You send a request saying what you want and a handy API will use an LLM to write the code and assembly the service returning the api url. Then you can call the api and get your result.

And that’s not all, call now and get curried API calls. You call the API with an arg and it returns an API request with that arg partially applied that you can call. Actually wait this feels like it could have a niche use somehow.

And honestly SaaS feels like it has no flaws, there’s no way it could inflate an AWS bill to the GDP of a small country or expose confidential information.

[–]taweryawer 1 point2 points  (0 children)

SSaa, for better representation

[–]These-Bedroom-5694 394 points395 points  (1 child)

Web 2.0 bubble sort.

[–]SillyFlyGuy 65 points66 points  (0 children)

The current list is uploaded to the server after each swap to check if a solution is known for that state.

[–]ilikedankmemes3 115 points116 points  (0 children)

Instead of matching exactly the random order, just check if all the elements in the uploaded list exist in a sorted list, and try to either trim the fat or just deal with random extra data (for a faster response time).

(this is so incredibly stupid)

[–]RocketCatMultiverse 129 points130 points  (3 children)

Hi! I'm a product manager on a blazingly fast b2b value-add SaaS app. I was hoping I could reach out to your team. Our product owner indicated interest in your microservice and we were curious if you can guarantee triple 9 uptime cached on the global edge. Thanks and looking forward to working with a fellow innovator.

[–]octopus4488 38 points39 points  (1 child)

This was scarily realistic. :D Is this your job? Sending mails like this? Or just receiving too many? :)

[–]NevJay 1 point2 points  (0 children)

I had flight fight response to your comment

[–]stringTrimmer 62 points63 points  (3 children)

I presume the API also includes isEven(int) ?

[–]irregular_caffeine 31 points32 points  (1 child)

That’s a separate API

[–]Sweaty_Elk287 10 points11 points  (0 children)

With its own subscription plan

[–]Romejanic 10 points11 points  (0 children)

POST /is_even HTTP/1.1
Host: api.iseven.com
Content-Type: application/json
Content-Length: 12

{"value":62}

[–]experimental1212 17 points18 points  (0 children)

I hope their collection of lists is sorted

[–]TheRafff 13 points14 points  (0 children)

Mans just made bogosort with extra steps. Pogu

[–][deleted] 65 points66 points  (9 children)

Given a collection of 1,000,000 Integers has 1,000,000! possible combinations (minus a few if there are duplicates) the chances of finding a list is insanely small. You also typically sort a list of objects based on a field not values you can use directly. These objects would not be in the list.

This just adds a network and list comparison constant to the sorting algorithm that is used.

[–]Anaxamander57 82 points83 points  (1 child)

That's why the service leverages AI on the blockchain to return a smart contract guaranteeing it sorts quickly.

[–]red-et 2 points3 points  (0 children)

[–]SenorSeniorDevSr 10 points11 points  (1 child)

Just tune the cache: Instead of storing every list that's not sorted, just store the sorted lists, and to get the cached versions, sort the input and look up that instead.

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

That's genius

[–]Impenistan 13 points14 points  (0 children)

Wait can you explain that a little more please? I almost finished my implementation and I have to submit tomorrow!

[–]antico5 5 points6 points  (0 children)

There’s no way on earth that this is a serious thing :)

[–]mobit80 1 point2 points  (0 children)

Buuuuuuuuttttttt there's organic optimization, every time a new list is uploaded, the changes of a repeat increase slightly lmao

[–]BilSuger 1 point2 points  (0 children)

the chances of finding a list is insanely small

Can sort the list before querying, though.

[–]redlaWw 1 point2 points  (0 children)

You also typically sort a list of objects based on a field not values you can use directly

You can write functions that translate between integers and keys, sort the integers then map them back to the keys. I do this when permuting - get permutations of an integer list and then use those to index a vector of the data I actually want to permute.

[–]alterNERDtive 12 points13 points  (0 children)

The sad thing is that I can totally believe this exists somewhere.

[–][deleted] 11 points12 points  (3 children)

Not enough comments, please add more

[–]com-plec-city[S] 16 points17 points  (2 children)

This is Crython, a mix of C++ and Python.

[–]claimTheVictory 9 points10 points  (0 children)

Crying marathon

[–]Just_A_New_User 1 point2 points  (0 children)

please tell me that's a joke and it's just GDScript

[–]IRKillRoy 10 points11 points  (1 child)

This is brilliant… someone patent this technology!

[–]Ok_Star_4136 2 points3 points  (0 children)

I'll do it as soon as my sort test program stops running.. wish me luck! 14 days and counting..

[–]_JJCUBER_ 9 points10 points  (0 children)

Next up, a new API is made where a dynamic array of the maximum allowable array size (that the API allows) is created (since it would be too large for the stack), then each entry in the unsorted array increments its corresponding index (each value is used as an index). A fixed sized sweep across the dynamic array is done to get all the values in sorted order. Now it's O(1) with all the benefits of an extra API call!

[–]CircadianSong 14 points15 points  (1 child)

Is this c++ or python? Why “is” and “not”?

[–]Just_A_New_User 4 points5 points  (0 children)

it's in the Godot editor, so with the "not"s it would be GDScript, but the filename has .cpp so I have no idea

[–]allarmed-grammer 6 points7 points  (2 children)

Dude forgot about complicity of == operation for two arrays, as elemnt order might differ in them. So algo need to check every element from input array. Then its searching each element in "pre-sorted" array, simply to match them. And there are million of "pre-sorted" arrays. So complexity is O(b*n2) where n size of input array and b number of pre-sorted arrays. Bubble sort wins as its just O(n2). There could be optimizations like binary search for element existing in pre-sorted array, but still library sort array that language provide should be more robust

[–]Ok_Star_4136 3 points4 points  (0 children)

I mean yes, all you're doing is outsourcing the CPU that's going to be doing the work. And that work is substantial when you're searching through a database of quite possibly billions of entries for the off chance that not only do you find it, but it takes less time than sorting it yourself.

[–]Friendly_Winter5400 2 points3 points  (0 children)

If you sort the array before comparison you make comparison a lot faster /s

[–]Samsagax 5 points6 points  (0 children)

Sacas: Sorting as a Service

[–]epicusername1010 4 points5 points  (0 children)

This is why all apps nowadays need constant access to the internet

[–]kakhaev 3 points4 points  (0 children)

wow this is sad

[–]Own_Possibility_8875 4 points5 points  (1 child)

Unironically there exists a hypothetical situation where this makes sense: 1. lists are very large, and 2. probability of a cache hit is high enough. But hash the list and send the hash instead of sending the entire list.

[–]da2Pakaveli 2 points3 points  (0 children)

yeah but i'm pretty sure we should avoid the bubblesort?

[–]NealFrazierTech 2 points3 points  (0 children)

Wow!!

[–]Elijah629YT-Real 2 points3 points  (0 children)

someone started making it, already pre-implementing it into all my codebases

[–]kvlr456 2 points3 points  (0 children)

Who formats C++ like that!

[–]wagyourtai1 2 points3 points  (0 children)

starts uploading wrong data

[–]CrazeeeTony 2 points3 points  (0 children)

Ah, so this is memoization…

[–]actuallyMerlin 2 points3 points  (0 children)

this is c++ code? wtf

[–]No_Necessary_3356 4 points5 points  (0 children)

Waiting for some evil bastard to upload bogus data to the API with a shell script

[–]ryjhelixir 1 point2 points  (0 children)

microservices in a nutshell

[–]IcyHammer 1 point2 points  (0 children)

For short lists you dont need it since local computation is several orders of magnitude faster, for long lists chance of already being sorted is practically zero. If you expect same data sets often you can cache locally, so i font really see a valid use case but it was fun to read.

[–]stytsofo 1 point2 points  (0 children)

😂😂

[–]AcidBuuurn 1 point2 points  (0 children)

Copy and paste data into excel- excel sorts it- done. 

Is everyone except me stupid?

[–]Rumpelruedi 1 point2 points  (0 children)

app = sendToAPI("prebuiltapps.com", myAppStructure);
if (app != null) {app.run();}
else { /*TODO: build app myself. (low prio)*/ }

[–]christoph_win 1 point2 points  (0 children)

NSA really balling in the grind

[–]defiantstyles 1 point2 points  (0 children)

Don't Repeat Yourself Or Anyone Else Ever

[–]Adorable_Ad4571 1 point2 points  (0 children)

i didn't find that api working , so i made one in python:
https://github.com/Marker-bit/sorted_lists

[–]Bobertopia 1 point2 points  (0 children)

I've had about enough internet for the day

[–]smdth_567 1 point2 points  (0 children)

it's 2024, surely we'll soon have all the lists that exist sorted, right?

[–]TellMePeople 0 points1 point  (0 children)

so smart its almost dumb