Readline insists in ordering the returned array

Hi, I want to use Ruby Readline for a custom console. Commands are
“ddd”, “bbb”, “aaa”, “ccc” and I want they to be shown in that order
when pressing TAB with empty buffered line. Example code:


#!/usr/bin/ruby

require “readline”

commands = %w{ddd bbb aaa ccc}

Readline.completion_proc = proc do |s|
commands
end

while line = Readline.readline(">>> ", true)
end

Running it:

TAB
aaa bbb ccc ddd

I strongly need that the commands are shown in the original order! but
Readline shorts them:

TAB
ddd bbb aaa ccc

Being a C ruby code I expect it’s hard to monkey patch it. Maybe I
miss something to keep the order of the array?

Thanks a lot.