Language: C++

#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int n;

	cin >> n;

	string s[110];
	int pp[110];
	vector<pii> p(n);

	rep(i, n) {
		cin >> s[i];
		cin >> pp[i];
		p[i] = make_pair(pp[i], i + 1);
	}
	
	sort(s->at(0), s->at(n));

	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			int flag = i + 1;
			while (s[i] == s[i + 1]) {
				flag = i + 1;
				i++;
			}
			sort(p[i], p[flag]);
		}
	}

	rep(i, n) {
		cout << p[i].second << endl;
	}

}

Compiler output:
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = pair<int, int>]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:69:8:   required from here
   69 |                         sort(p[i], p[flag]);
      |                         ~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::pair<int, int>' and 'std::pair<int, int>')
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::pair<int, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1906:50: note:   'std::pair<int, int>' is not derived from 'const std::move_iterator<_IteratorL>'
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = char]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:6:   required from here
   60 |         sort(s->at(0), s->at(n));
      |         ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:32: error: no matching function for call to '__insertion_sort(char&, int, __gnu_cxx::__ops::_Iter_less_iter&)'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1770:5: note: candidate: 'template<class _RandomAccessIterator, class _Compare> void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)'
 1770 |     __insertion_sort(_RandomAccessIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1770:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1817:32: note:   deduced conflicting types for parameter '_RandomAccessIterator' ('char' and 'int')
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1818:42: error: no matching function for call to '__unguarded_insertion_sort(int, char&, __gnu_cxx::__ops::_Iter_less_iter&)'
 1818 |           std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1819 |                                           __comp);
      |                                           ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1794:5: note: candidate: 'template<class _RandomAccessIterator, class _Compare> void std::__unguarded_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)'
 1794 |     __unguarded_insertion_sort(_RandomAccessIterator __first,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1794:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1818:42: note:   deduced conflicting types for parameter '_RandomAccessIterator' ('int' and 'char')
 1818 |           std::__unguarded_insertion_sort(__first + int(_S_threshold), __last,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1819 |                                           __comp);
      |                                           ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:1889:38:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = char; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1889 |             std::__unguarded_partition_pivot(__first, __last, __comp);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1905:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1905 |           std::__introsort_loop(__first, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1907 |                                 __comp);
      |                                 ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = char]'
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:6:   required from here
   60 |         sort(s->at(0), s->at(n));
      |         ~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1855:34: error: no matching function for call to '__move_median_to_first(char&, int, char&, int, __gnu_cxx::__ops::_Iter_less_iter&)'
 1855 |       std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1856 |                                   __comp);
      |                                   ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:85:5: note: candidate: 'template<class _Iterator, class _Compare> void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare)'
   85 |     __move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b,
      |     ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:85:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1855:34: note:   deduced conflicting types for parameter '_Iterator' ('char' and 'int')
 1855 |       std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1856 |                                   __comp);
      |                                   ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1857:40: error: no matching function for call to '__unguarded_partition(int, char&, char&, __gnu_cxx::__ops::_Iter_less_iter&)'
 1857 |       return std::__unguarded_partition(__first + 1, __last, __first, __comp);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1829:5: note: candidate: 'template<class _RandomAccessIterator, class _Compare> _RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
 1829 |     __unguarded_partition(_RandomAccessIterator __first,
      |     ^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1829:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:1857:40: note:   deduced conflicting types for parameter '_RandomAccessIterator' ('int' and 'char')
 1857 |       return std::__unguarded_partition(__first + 1, __last, __first, __comp);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algo.h:61:
/usr/include/c++/14/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator,