An open API service indexing awesome lists of open source software.

https://github.com/ho11ow1/sorting_algorithm

Simple sorting algorithm using 2 for loops and template arguments supporting both Vector and standard[] arrays
https://github.com/ho11ow1/sorting_algorithm

algorithms cpp header-only sorting template

Last synced: 9 months ago
JSON representation

Simple sorting algorithm using 2 for loops and template arguments supporting both Vector and standard[] arrays

Awesome Lists containing this project

README

          

# Sorting_algorithm

A simple yet effective sorting algorithm in `C++` using templates to support both vectors and arrays.

## Features

* Template-based implementation
* Two distinct sorting implementations:
* `vector`: Specialized for std::vector
* `type`: Works with standard arrays
* Simple selection sort algorithm
* Header-only implementation
* Namespace organization for clean code structure

## Usage Example
```cpp
#include "sort.h"

// Vector sorting example
void vectorExample()
{
std::vector 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]);
}
}
```
## Installation Guide

### Option 1: Direct Include
1. Download `sort.h`
2. Add it to your project
3. Include the header: `#include "sort.h"`

### Option 2: Git Clone
```bash
git clone https://github.com/Ho11ow1/Sorting_algorithm
```

### Troubleshooting
* Ensure `sort.h` is in your include path
* Check C++ version compatibility
* Verify STL is available