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
- Host: GitHub
- URL: https://github.com/ho11ow1/sorting_algorithm
- Owner: Ho11ow1
- License: gpl-3.0
- Created: 2024-08-31T11:24:01.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-11-17T15:48:43.000Z (about 1 year ago)
- Last Synced: 2025-02-07T23:35:55.607Z (11 months ago)
- Topics: algorithms, cpp, header-only, sorting, template
- Language: C++
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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