0

I am a beginner of C++. I learned a function code vector() name1; and use sort(name1.begin(), name1.end(), cmp) to help sort my vector array. My teacher told me that sort is the fastest way to sort,but I want to know how and why. The Final question is how to sort a two-dimensional array in the function code sort.

Evg
  • 25,259
  • 5
  • 41
  • 83
  • 1
    `std::sort` is not fastest, but is good enough on average and is asymptotically optimal. The question about sorting 2D arrays is asked here several times a week, please use search. – Evg Apr 20 '20 at 04:08
  • What *exactly* do you mean by "sort a 2d array"? There are multiple things that can be called that. Are you free to move the inner elements to anywhere or do they have to stay together? – Caleth Apr 20 '20 at 09:22

1 Answers1

0

std::sort is not the fastest sorting technique but yeah it's optimal and works for large range of inputs quick sort algorithm sorts the one dimensional vector in least time click here to know how inbuilt sorting works

For sorting a 2-D dimensional vector one has to specify whether to sort the elements in column-wise or row-wise,there is no inbuilt function for sorting You can see the previous threads on sorting a 2-D vector sorting of a 2-d vector

Giriteja Bille
  • 168
  • 1
  • 13