fix Array.sort (PR#33)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2965 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2000-03-16 16:43:43 +00:00
parent 078a40e1d6
commit d512c37344
1 changed files with 3 additions and 0 deletions

View File

@ -63,6 +63,9 @@ let array cmp arr =
end;
let pivot = unsafe_get arr mid in
let i = ref (lo + 1) and j = ref (hi - 1) in
if not (cmp pivot (unsafe_get arr hi))
|| not (cmp (unsafe_get arr lo) pivot)
then raise (Invalid_argument "Sort.array");
while !i < !j do
while not (cmp pivot (unsafe_get arr !i)) do incr i done;
while not (cmp (unsafe_get arr !j) pivot) do decr j done;