compare 함수를 써서 앞부터 내림차순 정렬을 해도 되고,
rbegin(), rend()를 해서 뒤에서부터 오름차순 정렬을 해도 된다.
// Compare 함수
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(const char &a, const char &b)
{
return a > b;
}
string solution(string s) {
sort(s.begin(), s.end(), compare);
string answer = s;
return answer;
}
// rbegin(), rend()
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(string s) {
sort(s.rbegin(), s.rend());
string answer = s;
return answer;
}