My understanding was that when referencing data within an array, the counting started at zero. For example, the zeroth object in array = ["cat", "dog", "fish"] would be "cat".
The tutorial that I am working on says to do it like this (let’s say we are sorting by length of string for example).
array.sort {|value1,value2| value1.length <=> value2.length }
This does sort it how I want it, but my question is, if counting in array begins at “0”, how come we are not doing it like this:
array.sort {|value0,value1| value0.length <=> value1.length }
value1andvalue2are just names or placeholders for each pair of values in the array. You could put another you like there: