Reducing the sorting time of a large number of numbers I have to sort many large numbers in a given time limit. The program below works, but not when the test cases reaches \$10^6\$, in which case it exceeds the time limit.

def tsort(tests)
        sorted_array = []
        1.upto(tests) do
            input_num = gets.chomp.to_i
            sorted_array[input_num] = 1
        end
        #puts sorted_array.sort!
        sorted_array.each_index {|index| puts index if sorted_array[index] == 1}
    end

    test_cases = gets.chomp.to_i
    tsort(test_cases)


I wanted to ask if there was a better way to do this. Perhaps an algorithm will help me accomplish this.
Single Responsibility and Lying Names
The tsort method does too much. It both gets input from the user and stores that information in an array (a potentially large one at that, but more on that later). Then it prints the array. You should have three separate methods here and tsort should do one thing, sort an array. As it is, nothing actually gets sorted per se. You're just keeping the list sorted, which seems smart, but...
Performance
Think about what happens when I give gets.chomp.to_i the number 100. The number 1 gets placed into the 100th position of the array. To get it back out, we have to then iterate over 100 positions. If I give it 1000 instead, we now have to make 1000 iterations in order to find it. That's 10 times as many iterations. This method gets exponentially slower. It is no surprise that inputting 10^6 exceeds the time constraints; it takes 10^6 iterations to print the number, even if it's the only number in the array.
This can be solved by implementing any number of well studied sorting algorithms. A quick google search should get you started. I recommend learning to bubble sort first, then move on to the more efficient algorithms. This assumes you're doing this for educational purposes. Otherwise, just use Ruby's built in Array#sort method.