Sorting

Python Sorting Interview Questions

Sorting questions are about ordering by something other than the obvious: a value you calculate, two columns at once, or a rule somebody described in words.

What sorting questions ask you to do

Across the questions here, these are the shapes that come up:

  • Order by two columns going in opposite directions
  • Order by a value you work out rather than one stored
  • Keep the original order among equal items
  • Return the top few without sorting everything

Common mistakes with sorting

Python keeps equal items in their original order, which is what makes sorting twice work as a way of ordering by two columns — but only if you sort by the less important column first. Doing it the other way round throws the first sort away completely.

Questions to practice

Questions last reviewed 19 October 2026.

Roles this comes up in

Companies these come from

Other topics