Sorting with C/C++

Since I'm too lazy to learn how to sort with the STL, here is a simple way to sort arrays in C using a function pointer. (Source is at the bottom of the page.) It works with simple data types or even structs or objects. Here's the function prototype: Not too bad. In fact, after I'd finished everything I found out there's already a sort routine in the c library with the exact same function definition. The only thing the user has to supply is a function to compare two elements of the array. This comparison function can even be a member of a class. Here's a simple example of a function to compare ints. The function call would look like this: Like I said, the function works with Objects too - we can test it with this simple Circle class. Presuming that we assign some value to each object's diameter, we can sort the circles through a call like this: Source
sorting.h
sorting.cpp