In order to sort the data inside the table valued function. Set a primary key on the sort column, you might also want to make this the first column in the table..
The API is giving the same output as the function. So calling the function from the database without a sort order would give the same result. For a future release the development team will look into a possibility to sort on an API call. For now the best option is to add the PK to force the sorting.