Chapter 5: Page 90 - 'Creating a More Complex Sort Function'

In this section, the function sortLevelNameAsc should really be called compareByLevelThenName and the text should be updated to reflect this. The implementation of the function should be as follows:

 function compareByLevelThenName(a, b)
   if a.level == b.level then
     if a.name < b.name then
       return true
     else
       return false
     end
   else
     if a.level < b.level then
       return true
     else
       return false
     end
   end
 end

While this code is equivalent to the existing sortLevelNameAsc definition, the concepts explored in this section can be lost when using the shorter example.