diff --git a/astronaut/freshnaut b/astronaut/freshnaut index 6835c04..d2e630a 100755 --- a/astronaut/freshnaut +++ b/astronaut/freshnaut @@ -10,6 +10,24 @@ check = What file (sat) or directory (dir) to check save = What file (sat) or directory (dir) to save known versions into]], arg[0])) end +-- Shamelessly stolen from http://stackoverflow.com/questions/15706270/sort-a-table-in-lua +function spairs(t) + -- collect the keys + local keys = {} + for k in pairs(t) do keys[#keys+1] = k end + + table.sort(keys) + + -- return the iterator function + local i = 0 + return function() + i = i + 1 + if keys[i] then + return keys[i], t[keys[i]] + end + end +end + function call(command) --[[-- -- Runs a command, returns all output except trailing newline on success. @@ -148,7 +166,7 @@ function check_new_versions(satellite, version_file_path) assert(version_file, "Failed to create " .. version_file_path) end - for version, _ in pairs(versions) do + for version, _ in spairs(versions) do if old_versions then if not old_versions[version] then print("\x1B[1K\r" .. satellite .. ": " .. version)