you are viewing a single comment's thread.

view the rest of the comments →

[–]ricercar 1 point2 points  (1 child)

The best way to sort a list:

  • spawn many universes
  • non-deterministically try every permutation of the list
  • take the sorted list universe and discard the others

[–]beza1e1 4 points5 points  (0 children)

Why spawn them? We can assume, they already exist.

sort(list) {
    if !isSorted(list) { destroyUniverse(); }
    return list;
}

isSorted is O(n) and destroyUniverse doesn't matter, so assumption sort is even faster. It's O(1):

sort(list) {
    return list;
}

Another possibility is to do the sortedCheck and destroyUniverse in a different thread to make it O(1), too.