B
B
BranchInCode2019-02-10 23:20:46
C++ / C#
BranchInCode, 2019-02-10 23:20:46

How to sort an array by Unicode?

Initial array: [1, "Goose", 14, "gas", /, "file10", "file11"];
Sorted array: [/, 1, 14, "Goose", "file10", "file11", "gas"];
What sorting algorithm should be used? If it's not difficult, then throw links to the desired algorithm or throw off a whole piece of the algorithm, if you used it ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-02-11
@Vetka_in_code

If you do not believe your eyes and still an array.

https://ru.cppreference.com/w/cpp/algorithm/sort
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
  vector<wstring> words = { L"1", L"Goose", L"14", L"gas", L"/" , L"file10", L"file11" };
  sort(words.begin(), words.end());

  for(auto s : words)
  {
    wcout << s << " ";
  }
  wcout << endl;
  wcin.get();
}
OUT: / 1 14 Goose file10 file11 gas

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question