Skip to content

Commit

Permalink
Merge pull request JuliaLang#8848 from stevengj/sortier
Browse files Browse the repository at this point in the history
slight reduction in the number of comparisons for quicksort
  • Loading branch information
stevengj committed Oct 30, 2014
2 parents 2f5549d + 20ca7ce commit 77d7649
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,11 @@ function sort!(v::AbstractVector, lo::Int, hi::Int, a::QuickSortAlg, o::Ordering
v[mi], v[lo] = v[lo], v[mi]
end
if lt(o, v[hi], v[mi])
v[hi], v[mi] = v[mi], v[hi]
end
if lt(o, v[mi], v[lo])
v[mi], v[lo] = v[lo], v[mi]
if lt(o, v[hi], v[lo])
v[lo], v[mi], v[hi] = v[hi], v[lo], v[mi]
else
v[hi], v[mi] = v[mi], v[hi]
end
end
v[mi], v[lo] = v[lo], v[mi]
i, j = lo, hi
Expand Down

0 comments on commit 77d7649

Please sign in to comment.