Skip to content

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

License

Notifications You must be signed in to change notification settings

Ho11ow1/Sorting_algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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_sort: Specialized for std::vector
    • type_sort: Works with standard arrays
  • Simple selection sort algorithm
  • Header-only implementation
  • Namespace organization for clean code structure

Usage Example

#include "sort.h"
#include <iostream>

// Vector sorting example
void vectorExample() 
{
    std::vector<uint32_t> nums = { 1, 7, 3, 8, 2 };
    std::vector<uint32_t> sorted = Hollow::vector_sort::sort(nums);
    for (int i = 0; i < nums.size(); i++)
    {
        printf("%d%s", sorted[i], " ");
    }
}

// Array sorting example
void arrayExample() 
{
    char arr[] = { 'a', 'c', 'f', 'b' };
    int size = sizeof(arr) / sizeof(arr[0]);
    Hollow::type_sort::sort(arr, size);

    for (int i = 0; i < size; i++) 
    {
        std::cout << 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

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages