Skip to content

Sort by Weight with an LLM

Write a program in your preferred programming language that sends the following prompt to an LLM (e.g. a locally hosted LLM executed using Ollama):

Please sort the following objects by weight from lightest to heaviest: pencil, book, paperclip

and asks the LLM to respond only with a JSON document structured as follows:

{
  "objects": [
    "paperclip",
    "pencil",
    "book"
  ]
}

Your program should:

  1. Send the prompt to the LLM.
  2. Receive the JSON response.
  3. Parse the JSON to extract the ordered list of objects.
  4. Print the ordered objects to standard output as follows:
paperclip
pencil
book

Upload your solution in a GitHub repository, include a README file with clear instructions on how to set up and run your program, and then share the repository with me.


Last update: November 24, 2025