Number Sorting
Explore how to sort an array of numbers manually in Ruby by iterating, comparing, and swapping elements. Learn to access array indexes, loop within ranges, and implement sorting logic without built-in functions to strengthen your problem-solving skills.
We'll cover the following...
We'll cover the following...
Problem
Write a program that asks the user to input 10 numbers, then sorts them into ascending order.
Note: Built-in sorting functions are not allowed.
Please enter 10 numbers:10873459126The numbers in order: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Sorting a list of numbers
Purpose
Iterate over an array
Swap variables
Access elements in an array using an index
Loop over an array from specific index range
Analyze
Imagine that we have 5 coins with different values. How do we sort ...