Actually, the code given in the question is correct, and it does return the correctly sorted results.
The problem I was having was unrelated to Elastica and the code given in the question.
Turns out that the results I was retuning in my HTML were unsorted because I was not returning my Elastica Query results but the corresponding objects from my SQL database that were obtained from a query like this:
SELECT * FROM ...
WHERE id IN([ids from Elastica results in order])
The above SQL query does not return results in the order of the ids given in the "IN" clause, so it was necessary to re-order the SQL results to match the order of my ElasticSearch results (which I did with foreach statements). If I had been using MySQL I could have used ORDER BY FIELD(id, \[ids in order\])
to get SQL results in the same order as the ids provided in the IN clause.