At this point you don't (yet) have the gem specification which holds the date.  You will need to fetch it, see: https://github.com/rubygems/rubygems/blob/e07d5febb5d5b75be67fb861d9bae709d5a944c8/lib/rubygems/commands/query_command.rb#L214

You should also sort by date then name:

```ruby
[tuples.first.first.date, n.downcase]
```