Exercise: Sorting and Iterating

Let's test how to sort and iterate vectors.

We'll cover the following

This exercise is all about sorting lists and using iterators to extract data from them.

Problem statement

Given a list of numbers, you need to:

  1. Sort the numbers.
  2. Print the second number in the sorted list.
  3. Print the first number in the sorted list.
  4. Print the last number in the sorted list.

The list of numbers for you to work with is provided.

Coding challenge

Everything you need is in the Deeper Dungeons chapter. We encourage you to try solving it yourself before looking at the solution.

Get hands-on with 1400+ tech skills courses.