sorting ints unexpected results

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main(){
    std::vector<double> v = {10.5,5,3,23,4,5,1,10.9};
    sort(v.begin(), v.end());
    for (auto i: v)
        std::cout << i << ' ';
    std::cout << std::endl;
    sort(v.begin(), v.end(), std::greater<int>());
    for (auto i: v)
        std::cout << i << ' ';
}


this code gives this result:
1
2
1 3 4 5 5 10.5 10.9 23 
23 10.5 10.9 5 5 4 3 1 

why would it give 10.5 before 10.9 on the reverse sort?
nevermind, i just figured out that i put int in greater, thus the reason
Topic archived. No new replies allowed.