Using sort on a scalar context has undefined behavior. Assign the result of the sort into an array and return that. Change-Id: I180ba1dfcafe6e49132a38bd01be715718a4dff1