Sort using a functor

I have two programs over here.
Set.cpp

using namespace std;
typedef pair<int, int> pairs;

struct sort_asc
{
template
bool operator()(const t& a, const t& b)
{
return (a.second > b.second);
}
};

int main() {
int n;
cin >> n;

set<pairs> st;

for(int i = 0; i < n; i++)
{
	int t;
	cin >> t;
	st.insert({t, n - i});
}
set<pairs, sort_asc> st_asc(st.begin(), st.end());

set<pairs>::iterator it = st_asc.begin();

for(; it != st_asc.end(); it++)
	cout << it->first <<" " << it->second<<endl;

}

vector.cpp
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
return (a.first < b.first);
}

int main()
{
int n;
cin >> n;
vector< pair <int, int> > vect;

for (int i=0; i < n; i++) 
{
	int t;
	cin >> t;
	vect.push_back(make_pair(t, n - i) ); 
}


sort(vect.begin(), vect.end(), sortbysec); 

cout << "The vector after sort operation is:\n" ; 
for (int i=0; i<n; i++) 
{ 
	cout << vect[i].first << " "<< vect[i].second << endl; 
} 
return 0; 

}

When i am trying to use the functor in the set without the struct defination, it gives error. But when we do the same in vector it works fine.
Why does it happen?

Can you use functor in sets?
I think you can’t. Please check documentation.
In set, ascending order sorting is fixed i think.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.