233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
# File 'lib/compare-sort.rb', line 233
def self.sort_section(data, start_loc, end_loc)
return data if end_loc - start_loc <1
wall = start_loc
pivot = data[end_loc]
for i in start_loc..end_loc if data[i]<pivot
smaller_datum = data[i]
data.delete_at(i)
data.insert(wall, smaller_datum)
wall += 1
end
end
data.insert(wall, pivot)
data.delete_at(end_loc + 1)
self.sort_section(data, start_loc, wall-1)
self.sort_section(data, wall+1, end_loc)
end
|