I have created several arrays, containing multiple integers. Now i want the integers to be sorted, lowest first. Say for instance, i have this in an array: 6,6,1,2,4,4, i want it to be sorted: 1,2,4,4,6,6. Also, is there anyway i can make ruby recognize the 4 lowest values, and display them somehow? I have tried to mess around with .show, but since im quite new to programming i’m rather confused by the results i receive.
I have created several arrays, containing multiple integers. Now i want the integers to
Share
did you try this?
sortwill sort in ascending order.if you need them sorted in descending order, use
sortwith a block:UPDATE: not sure how i missed the part about lowest values …
thank you @Mladen