# -1 if a < b
# 0 if a = b
# 1 if a > b
- protected meth compare(a: E, b: E): Int is abstract
+ protected fun compare(a: E, b: E): Int is abstract
# Sort `array' using the `compare' function.
- meth sort(array: Array[E]) do sub_sort(array, 0, array.length-1)
+ fun sort(array: Array[E]) do sub_sort(array, 0, array.length-1)
# Sort `array' between `from' and `to' indices
- private meth sub_sort(array: Array[E], from: Int, to: Int)
+ private fun sub_sort(array: Array[E], from: Int, to: Int)
do
if from >= to then
return
end
# Quick-sort `array' between `from' and `to' indices
- private meth quick_sort(array: Array[E], from: Int, to: Int)
+ private fun quick_sort(array: Array[E], from: Int, to: Int)
do
var pivot = array[from]
var i = from
end
# Bubble-sort `array' between `from' and `to' indices
- private meth bubble_sort(array: Array[E], from: Int, to: Int)
+ private fun bubble_sort(array: Array[E], from: Int, to: Int)
do
var i = from
while i < to do
class ComparableSorter[E: Comparable]
special AbstractSorter[E]
# Return a <=> b
- redef meth compare(a, b) do return a <=> b
+ redef fun compare(a, b) do return a <=> b
init do end
end