| 232 | } |
| 233 | |
| 234 | func quickSort(toSort Sortables, left int, right int) { |
| 235 | low := left |
| 236 | high := right |
| 237 | pivot := toSort[(left+right)/2] |
| 238 | |
| 239 | for low <= high { |
| 240 | for toSort[low].Compare(pivot) { |
| 241 | low++ |
| 242 | } |
| 243 | for pivot.Compare(toSort[high]) { |
| 244 | high-- |
| 245 | } |
| 246 | if low <= high { |
| 247 | Swap(toSort, low, high) |
| 248 | low++ |
| 249 | high-- |
| 250 | } |
| 251 | } |
| 252 | if left < high { |
| 253 | quickSort(toSort, left, high) |
| 254 | } |
| 255 | if low < right { |
| 256 | quickSort(toSort, low, right) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | // makeDefaultHeader(collection) returns the default header to be used in case |
| 261 | // the list to be printed is empty. |