#include <string>
#include <iostream>
#include <functional>
#include <algorithm>
#include <list>
#include <vector>

struct A
{
    std::string str ;
    double number ;

    // ...
};

std::ostream& operator << ( std::ostream& stm, const A& a )
{ return stm << "{'" << a.str << "'," << a.number << '}' ; }

int main()
{
    // const, immutable,
    const std::list<A> seq_in_physical_order { { "abc", 23.67 }, { "def", 11.05 }, { "ghi", 17.32 },
                                               { "jkl", 56.78 }, { "mno", 33.12 }, { "pqr", 40.71 } } ;

    std::vector< std::reference_wrapper< const A > > seq_in_logical_order( seq_in_physical_order.begin(),
                                                                   seq_in_physical_order.end() ) ;
    // perform a logical ordering with respect to the member 'number'
    std::sort( seq_in_logical_order.begin(), seq_in_logical_order.end(),
               [] ( const A& first, const A& second ) { return first.number < second.number ; }  ) ;

    std::cout << "in physical order:\n-----------------\n" ;
    for( const A& a : seq_in_physical_order ) std::cout << a << " @ " << std::addressof(a) << '\n' ;

    std::cout << "\n\n\nin logical order:\n----------------\n" ;
    for( const A& a : seq_in_logical_order ) std::cout << a << " @ " << std::addressof(a) << '\n' ;
    std::cout << '\n' ;

}
