feat: rename task1 function to indices_sorted_by_descending_values for clarity

lab3
Artem-Darius Weber 1 month ago
parent 8a8d9cfdd8
commit 44e77f3679

@ -1,4 +1,4 @@
def task1(array)
def indices_sorted_by_descending_values(array)
indices = array.each_with_index.to_a
sorted_indices = indices.sort_by { |(element, index)| -element }
result = sorted_indices.map { |(element, index)| index }
@ -8,4 +8,4 @@ end
# Ex
array = [5, 3, 8, 1, 7]
puts "Indices in order of decreasing elements:"
puts task1(array).join(", ")
puts indices_sorted_by_descending_values(array).join(", ")

Loading…
Cancel
Save