Trace a chosen sorting algorithm through a small list of numbers, showing every comparison, swap, and the list state after each step until sorted.
You are an instructor who thinks the phrase "and then the list gets sorted" is where most sorting explanations quietly give up on the actual mechanics, and your version never skips that part, every comparison and every swap gets shown as it happens, on a real list, so the sort is something a student watches unfold rather than a claim they take on faith. My sorting algorithm is [SORT:select:bubble sort,selection sort,insertion sort,merge sort,quicksort], and my dataset is [DATASET?], a short list of numbers. If I left [DATASET?] blank, generate a list of six to eight numbers in a random, clearly unsorted order for me. State the starting list clearly. Then trace [SORT] through the list one operation at a time. For bubble sort, selection sort, and insertion sort, show the two elements being compared at each step, state the comparison result, state whether a swap happens, and print the full current state of the list after every single comparison, not only after swaps, so a "no swap needed" step is just as visible as one that changes the list. Number each pass through the list clearly and note when a full pass completes with no swaps, since that is how these algorithms know they are finished. For merge sort, show the list being split into smaller sublists down to single elements, then show each merge step, comparing the front of two sublists and building the merged result one element at a time, printing the state of the merge at each step. For quicksort, show which element is chosen as the pivot, show the partitioning process moving smaller elements to one side and larger elements to the other, print the list state after partitioning completes at each level, and show how the algorithm then recurses into each partition. Continue until the full list is sorted, then print the final sorted list clearly on its own line, and state the total number of comparisons and the total number of swaps or merges the algorithm actually performed on this specific list. Close by asking if I would like to see the same starting list sorted by a different algorithm from the list above, so I can compare the actual number of comparisons and swaps each one takes on identical data, rather than only comparing them by abstract reputation for being fast or slow.
Use this prompt anywhere
10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.
Get Early AccessMost sorting explanations describe the idea, bubble sort compares neighbors and swaps them, and then jump straight to a sorted list with the actual mechanics glossed over. This tool doesn't skip that part. Every comparison and every swap gets printed as it happens on a real list, so sorting becomes something you watch happen instead of a claim you take on faith.
Pick a [SORT] from five common algorithms and bring your own [DATASET] or get a random six to eight number list generated. For bubble, selection, and insertion sort, every comparison prints the current state of the list, whether or not a swap happens, with passes numbered and the finishing condition, a full pass with no swaps, called out explicitly. For merge sort, the splitting down to single elements and the merge-back-together process both get shown step by step. For quicksort, the pivot choice and partitioning get shown at each level of recursion, with the list state printed after every partition.
The trace ends with the final sorted list and the actual total count of comparisons and swaps or merges the algorithm performed on your data, a concrete number instead of an abstract efficiency claim. Sort the same list with a different algorithm and compare those counts directly. Run it in the Dock Editor for a set of traced sorts, pair with the big o complexity explainer to connect comparisons to a complexity class, or the binary search practice generator to search the sorted result.
Paste this prompt into your AI assistant of choice, or open the Dock Editor. Choose [SORT] from bubble sort, selection sort, insertion sort, merge sort, or quicksort.
Provide [DATASET] as a short list of numbers, or leave it blank for a random six to eight number unsorted list.
For bubble, selection, and insertion sort, the list state prints after every single comparison, whether or not it results in a swap, with passes numbered clearly.
Merge sort shows the splitting and merging process step by step. Quicksort shows the pivot choice and partitioning at each level of recursion.
See the total comparisons and swaps or merges your algorithm actually used, then sort the same list with a different algorithm to compare those real numbers directly.
Watch bubble sort or insertion sort reorder a small list one comparison at a time, seeing the actual mechanics a textbook description usually skips over.
Trace exactly how a list gets split down to single elements and then merged back together, comparing the front of two sublists at each step.
See which element gets chosen as the pivot, watch the partitioning move smaller and larger elements to each side, and follow the recursion into each partition.
Sort the same starting list with two different algorithms and compare the actual number of comparisons and swaps each one took, turning an abstract speed comparison into real counted numbers.
Discover more prompts that could help with your workflow.
Build a small working program that calls a real public API, with the request, response, and API key setup explained step by step.
Explain a core functional programming idea, such as pure functions or immutability, with a broken code example and its fixed version shown side by side.
Explain a built-in math function, square root, power, absolute value, or rounding, covering math and syntax, then generate practice calls to predict before revealing results.
10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.