Re:Timsort, the Python sorting algorithm
by buildbot on Tuesday October 08, 2019 @07:42PM
(#21198489)
It seems way better to fail with a RuntimeException than to get possibly unsorted results that cause some hideous error deeper in your application.
[ Parent
| on HN ]
It depends on the contract.
It's good to have a contract that defines behaviour even in the case of invalid input.
That could be throwing an error, or it could be given unsorted input. Either way is ok.
(The C and C++ answer is to leave the behaviour in the face of invalid input undefined. Undefined means that anything goes, including formatting your hard disk.)