This is the third of a series of short posts in which I solve interview questions from my Professional Practices course using Ruby.
Sort the following array in numeric order:
var array1 = [1, 30, 4, 21, 100000];
Ruby understands that you would want to sort an array of numbers in increasing order.
array1 = [1, 30, 4, 21, 100000] array1.sort!
var array1 = [1, 30, 4, 21, 100000]; array1.sort((x, y) => x - y);