0

What is Sort (built-in function) with three parameters Do ?

for example : Sort (vec.begin() , vec.end() , cmp);

14th Jun 2017, 4:48 PM
Mostafa Gad
Mostafa Gad - avatar
4 Réponses
+ 2
cmp is a function used by Sort to determine if an argument is less than another. You write this function.
14th Jun 2017, 4:58 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 2
For examples you can write a class Bank to rappresent an bank account...if you have N objects and you want sort them, you can decide how to do it. You want order them according money? Or according creation date? You have to write a function that accepts two Bank objects and return a bool value. And in this function you choose what make an object smaller than another.
14th Jun 2017, 5:05 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
You're welcome.
14th Jun 2017, 5:08 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
0
0K .. thank u
14th Jun 2017, 5:08 PM
Mostafa Gad
Mostafa Gad - avatar