Number Sorting

Learn to sort a list of numbers in Ruby.

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:
10
8
7
3
4
5
9
1
2
6
The 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 ...