Try to use hints only when you really need help! The hints are arranged in order.
Hint 1This looks like a sorting problem. It might help to understand what sorting algorithms are out there. You can compare the speed of the algorithms by looking at their time complexities.
|Python||list.sort() or sorted()||C++||std::sort from algorithm standard library|
Hint 2Consider the followings notes/questions:
- Usually sorting allows us to sort lists of single numbers
- Is it possible to convert the tuple for r, g and b into a form that is more friendly for sorting?
- Or perhaps do the standard implementations allow you to use your own method to compare between two elements?
Hint 3Consider the following questions:
- Is there a way to combine r, g and b into a single number? (Maybe some arithmetic? Addition?)
- But how do we combine them in such a way that we can get the exact same r, g and b values back after sorting?
- Maybe we can think about how we can combine them to a number that reflects the relative importance of each colour component (i.e. r is more important than g and b)?