struct permuted{ list index; list::size_type bound; }; indexed.sort(compare); bool compare(const permuted& x, const permuted& y){ list::const_iterator i = x.index.begin(); list::const_iterator j = y.index.begin(); return *i < *j;