For these columns: food, nutrient1, nutrient2… I want to get the foods with the highest values for a nutrient in descending order.
With the above code the values in the nutrient column are not ordered.
request.body_json only contains data for well formed requests with Content-Type: application/json. Perhaps your problem is there.
What is get_data?
Are you trying to get a dict with the keys in the same order it was sent through a json request?
If this is the case, then (1) you should have stated this at the beginning and (2) this is a lot to ask. There are many moving parts and (as far as I know) none of them explicitly says in their documentation that a request preserves the order of the keys. A dictionary is converted to json, serialized in a request, sent, received, converted to python, serialized again, sent to the client, deserialized to javascript/python/skulpt…
If this is not the case, then I will repeat what @divyeshlakhotia and @p.colbert already said: please ask the question providing more details about what you do, what you get and what you want to get instead.