##Ruby##
Ruby
Everyone knows: sorting is very slow and takes many cycles (the best you can do is something with n log(n)). Thus it is quite easy to check if the array is sorted. All you have to do is compare the runtime of sorting the array and sorting the sorted array.
array = [1, 5, 4, 2, 3] ## measure the time needed to sort the array 1m times tstart = Time.now 1000000.times { array.sort } trun = Time.now - tstart ## now do a reference measurement on a sorted array array.sort! tstart = Time.now 1000000.times { array.sort } treference = Time.now - tstart ## compare run times if trun > treference print "array was not sorted" else print "array was sorted" end