Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is currently SFW (it seems to have images disabled).

But, the post that started it all is:

Man, am I a genius. Check out this sorting algorithm I just invented.

  #!/bin/bash
  function f() {
      sleep "$1"
      echo "$1"
  }
  while [ -n "$1" ]
  do
      f "$1" &
      shift
  done
  wait

  example usage:
  ./sleepsort.bash 5 3 6 3 6 3 1 4 7


It is currently SFW (it seems to have images disabled).

/prog/ is a text-only board.


There is an ASCII swastike with racist slur in the thread now.


That's actually a very clever hack. I'm not sure how I'll put it to use, but I'll definitely keep it in my mental store.


Well, I would hope you wouldn't use it to actually sort integers...but, yes, bash is surprisingly good at parallel jobs (or, at least, it is surprisingly easy to create parallel jobs in bash), and that's one way to go about it. One could bash together a cheap and cheerful queueing system with something like this...but only if order isn't all that important (race conditions are almost guaranteed), timing isn't all that important (Linux has high precision timers but bash/sleep don't use them, as far as I know; and you'd need RT patches to get near realtime performance from the kernel, anyway), and only if you know with reasonable certainty the bounds on how many things will be queued before-hand.

So...probably not very useful, after all. But, a fun thought experiment, regardless. I feel awake after reading the whole thread. Honestly, I wish there were more posts like this on HN.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: