# sorting advanced

Sort, Then Binary Search

Remember binary search, which needs a SORTED list? Now you can make your own sorted lists — the two skills click together. 🧩

You get an unsorted list of nums and a target (present, all values different). Sort the list, binary-search it, and print the target's position IN THE SORTED list.

Example:

Input: nums = [50, 10, 40, 20, 30], target = 40 Output: 3

Sorting gives [10, 20, 30, 40, 50], and binary-searching for 40 lands on position 3.

💡 need a hint?

sort-then-binary-search.py🔒 given lines are locked — write your code in between
loading...