C++ STL

Shaila Nasrin
Learn Coding Concepts with Shaila
4 min readSep 7, 2019

--

In this post I’m not doing in depth discussion on how these standard libraries works behind the scene. I will just show what they do and how to use them.

Sort

  • sort: It orders the elements from beginning to end in O(nlogn) complexity. By default it the elements in ascending order for numeric values and lexicographical ascending for string values. (* P.S. print() is not a stl, I have written the method to print the vector. you can see that in the source code I have provided in the end of the post)
  • stable_sort: Similar sort, stable sort orders the elements from beginning to end in O(nlogn) complexity. By default it the elements in ascending order for numeric values and lexicographical ascending for string values. The difference between sort and stable_sort is, if the the elements are equivalent then stable_sort guaranties to keep their same order.

--

--