Is there a way I can directly sort a winrt::Windows::Foundation::Collections::IObservableVector<T> without creating a new vector nor converting it to a std::vector<T>?
IObservableVector<int> numbers{ single_threaded_observable_vector<int>() };
numbers.Append(5);
numbers.Append(1);
numbers.Append(3);
std::sort(numbers.begin(), numbers.end());
The std::sort seems not to work on C++/WinRT collections, at least for me.
My further goal is to display sorted and filtered collection of complex objects in a GridView.
If direct sorting is not possible, what's the most efficient way of turning IObservableVector<T> into a std::vector<T>? Vice versa is quite straightforward single_threaded_observable_vector<T>(std::move(vec)).
Edit:
According to Raymond Chen's blog it's possible to copy a IVector<T> into a std::vector<T> with use of IVector<T>.GetMany(UInt32, T[]).
std::vector<int> vec(numbers.Size());
numbers.GetMany(0, vec);
However, I'm still unsure about the performance of copying large collections in a production app. Hope there's a better approach.