I'm pretty impressed by both Grok's and Gemini's static analysis of it. (I changed the name of the function to algo and asked them to figure out if it's supposed to be a sort algorithm or a search algorithm. Both got it right.)[1] If someone else could please check the same prompt on ChatGPT and Claude (which I don't have) please link.
search algorithms have a term to search and condition to stop, don't they? more like ask them to find what the function is meant to do, but the swap and comparison point to sorting pretty hard.
I checked Sonnet, Mistral (GLM-5) and ChatGPT (GPT-6) with my own prompt, free version. They all get it if they have enough time (Claude checks the paper, ChatGPT and Mistral check with python code). But otherwise Mistral and GPT thought it would sort in descending order. I think when they understand it's a trick question they can automatically trigger additional reasoning / tools and come up with the correct answer.
Just to be clear, the author's intention wasn't really unclear! I just said "determine if it is intended to be a sort algorithm or a search algorithm (the author's intention might be unclear)" to force Grok/Gemini to really analyze it, in reality it's clear that it is a search algorithm. I also changed the word iCantBelieveItCanSort in the function name to algo to further make sure that Grok/Gemini really analyzed it, since the function name made it clear what it does.