A simple yet effective sorting algorithm in C++ using templates to support both vectors and arrays.
- Template-based implementation
- Two distinct sorting implementations:
vector: Specialized for std::vectortype: Works with standard arrays
- Simple selection sort algorithm
- Header-only implementation
- Namespace organization for clean code structure
#include "sort.h"
// Vector sorting example
void vectorExample()
{
std::vector<uint32_t> nums = { 1, 7, 3, 8, 2 };
Hollow::vector::sort(nums);
for (int i = 0; i < nums.size(); i++)
{
printf("%d ", nums[i]);
}
}
// Array sorting example
void arrayExample()
{
char arr[] = { 'a', 'c', 'f', 'b' };
int size = sizeof(arr) / sizeof(arr[0]);
Hollow::type::sort(arr, size);
for (int i = 0; i < size; i++)
{
printf("%c ", arr[i]);
}
}- Download
sort.h - Add it to your project
- Include the header:
#include "sort.h"
git clone https://github.com/Ho11ow1/Sorting_algorithm- Ensure
sort.his in your include path - Check C++ version compatibility
- Verify STL is available