Live data from Hacker News

Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

gkoberger.github.io

21–30 of 86 posts

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#21
post #10

Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR 1 - http://stackoverflow.com/questions/3730510/#3730579

the website doesn't verify the accuracy of sort output. it just gives you the first SO answer that a) has a code snippet b) which is error-free c) and has a function that can be extracted and run ...for your input format, and returns the output of passing your input code into it. It's true to the xkcd mission, which is just to find SO answers until it returns something, not to actually confirm it was sorted correctly…

The alt-text on the linked comic says "...until the list is sorted." Ergo, one must verify that it is sorted before knowing whether to execute the next code snippet.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#23
More crazy sorting techniques from a recent reddit thread: https://redd.it/9s9kgn

Highlights:

- GenghisKhanSort: delete all elements except for the first, repopulate the list with successors of the first element - HitlerSort: Choose an element in the list you think is the best, then loop through the list removing any element that does not match. - ThanosSort: delete half the array. The arrays may or not be sorted, but it'll help for future sorting - TrumpSort O(0): the array is always sorted. Anyone who says otherwise is fake news.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#24
post #10

Is it just me, or do none of them sort this array correctly? ["zebra","apple","banana","5","bapple","banana","banana"] Correction, the page finally found this algorithm that sorts my array[1]. So I am disappointed with the verifier function on this web page and may need to submit a PR 1 - http://stackoverflow.com/questions/3730510/#3730579

Maybe they just have a different definition of "correctly" sorted.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#25
post #12
post #9

this should be tagged [2015]

[2013], at least: https://stackoverflow.com/questions/12137690/javascript-sort...

An attempt was made, but right now it's at "(2103)". Nice to know xkcd will still be around in the next century!

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#26
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

The standard attack in this case is that someone could steal your cookies (if they are Js cookies) or execute instructions on gkoberger.github.io without your permission, since that is the context.

The way you would do this is create an answer to one of these questions on stack overflow that includes malicious javascript.

However, it's kind of unlikely there is much you can do with it. Sometimes a site will share cookies with subdomains, but this is not likely for github because you are allowed to publish arbitrary js there, so that would be a huge security hole.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#27
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

Given that this site is not hosted on a domain where you have important session cookies (or where you’ve granted permissions like camera or location usage) I don’t see much problem with eval-ing untrusted code. Most of the common XSS threats just don’t apply here.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#28
post #26
post #3

Hilariously awesome. I'm curious whether the multiple warnings about running untrusted code in the browser are necessary. I feel like all websites are already untrusted code, and the browser is quite well sandboxed and protected from anything too bad happening. What is the worst case scenario here for the user within the JS ecosystem, under known avenues of attack, not counting an unknown zero day browser exploit?

The standard attack in this case is that someone could steal your cookies (if they are Js cookies) or execute instructions on gkoberger.github.io without your permission, since that is the context. The way you would do this is create an answer to one of these questions on stack overflow that includes malicious javascript. However, it's kind of unlikely there is much you can do with it. Sometimes a site will share coo…

This is why GitHub uses a separate domain (github.io as opposed to github.com) for user sites.

Re: Stacksort – Searches StackOverflow for sorting functions and runs them (2013)

#30
post #5

It only checks that the output is sorted, not that it's a sorted version of the original string. The first answer that apparently works has a comment stating that it fails with more than 2 duplicates; indeed I tried a list with three 3s and the resulting passing answer only had one of those threes.

that's because that answer is for how to find unique values in an array. it works as intended with any duplicates, stacksort just chose an answer that wasnt only sorting
Post reply on HN