Hello fellow programmers, I was wondering if this implementation of selection sort could be improved. Are there any things that I have done wrong?
template<typename Element>
void selection_sort(Element arr[], size_t size) {
auto index_toSort = 0u;
while (index_toSort < size) {
auto index_smallest = index_toSort;
for (auto index = index_toSort; index < size; ++index) {
if (arr[index] < arr[index_smallest]) {
index_smallest = index;
}
}
std::swap(arr[index_toSort], arr[index_smallest]);
++index_toSort;
}
}