Sorting in C++

preview_player
Показать описание


Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer

Gear I use:
-----------------

Рекомендации по теме
Комментарии
Автор

You just don't upload tutorial like others.. You teach the concepts like a teacher. Thank you so much Cherno

mavrix
Автор

This is what good teaching looks like and sounds like, it only took me 6-10 minutes to proficiently understand and code using C++ sorting. It takes 2 complex hours just to understand my professor. The simplicity speech this man has is impeccable!

TruckingWithSteve
Автор

Thank you Charno, u don't know how this series helped me.
Can u do a video summarising different *useful* data structures, their uses and how to choose between them if there's different choices.

naoufal
Автор

Awesome work, congrats!
Still, one key topic I've been waiting for long now is EXCEPTIONS. It could be great to have an explanation from you :)
Thankds, best programming series ever!

Oscar-cdrn
Автор

Hey Cherno! I am watching your entire playlist on c++ and i am loving it!
Thanks a lot for the effort you put in to your videos !
I had a request, could you please make a video on file handling ??
and Thankssss! You have truly made learning fun !

livleensinghchani
Автор

Mann, finally I got to learn the predicate parameters. Been searching that material for a while. Thank you :D

marvted
Автор

Good video. I like that this video was shorter than usual, yet you explained everything important

scewps
Автор

Thank you brother your tutorials helped me to understand c++ in a simple fashion..

mohansuri
Автор

Thanks bro. I love your videos, you're a saint on the programming community :D

icemotion
Автор

Listen to the outro song at 2x speed.







dope shit

ThePlayerNotJump
Автор

A sequence is sorted with respect to a comparator comp if for any iterator it pointing to the sequence and any non-negative integer n such that it + n is a valid iterator pointing to an element of the sequence. - CppRef. I read it 3 times to understand it. Put it into Grammarly, and it got 3 complains.

I would prefer: A sequence is sorted based on the comparator comp given the valid start iterator and end iterator. I know it might not be as technically precise, but man, that sentences is not human readable.

李景天
Автор

Thank you keep making these greate video

abdallaaltaay
Автор

My request is that you do a video with 5 user inputs stored in data then it sorts that list. Thanks!

randyrandall
Автор

for (int value : values)
is this some new shorter version of for loop?

nadrogiranihibiskus
Автор

Same program but in C# (if someone need it):
Simplest variant:
using System;

class Program
{
static void Main()
{
int[] values = { 3, 5, 1, 4, 2 };
Array.Sort(values);

foreach (int item in values)
{
Console.WriteLine(item);
}

Console.ReadKey();
}
}
Output:
1
2
3
4
5
Hardest variant:
using System;

class Program
{
static void Main()
{
int[] values = { 3, 5, 1, 4, 2 };
Array.Sort(values, (int a, int b)=>
{
if (a == 1)
return 1;
if (b == 1)
return -1;

if (a > b)
return 1;
else
return -1;
});

foreach (int item in values)
{
Console.WriteLine(item);
}

Console.ReadKey();
}
}
Output:
2
3
4
5
1

igorthelight
Автор

It's nice to notice in cppreference: the parameter type is 'randomit' meaning sort will not work for containers not returning random iterators like list.

mayankdixit
Автор

I wish c++ could sort along strides elements.

Like only sort the even indexed elements inplace, our every 5th element.

Kramer-tt
Автор

So if I wanted to sort an array of custom objects (say a Person class which has a Name and an Age attributes and I wanted to sort them by their Age) would that be specified in the lambda/function section? Kind of like:

std::vector<Person> people = { *insert some objects here* }
std::sort(people.begin(), people.end(), [](Person& a, Person& b){ return a.GetAge() < b.GetAge()}

GetAge() being the getter for Age..

michaldvorak
Автор

awesome series! can you please do a video on iterators and streams?

elultimopujilense
Автор

oh! It's magic !Thank you! I really have learned a lot from this video.Having known the convenient std::sort, i don't have to write the original sort function such as insertion_sort, Heap_sort and Merge_sort, which is very helpful for C++ beginners

uarnvor