From 2221c56fc5292b71f3fa422275cb8924b999481e Mon Sep 17 00:00:00 2001 From: MikeGitb Date: Tue, 6 Dec 2016 00:09:19 +0100 Subject: [PATCH] [algorithm] Add sort --- gsl/gsl_algorithm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gsl/gsl_algorithm b/gsl/gsl_algorithm index c77e258..fc5b101 100644 --- a/gsl/gsl_algorithm +++ b/gsl/gsl_algorithm @@ -126,6 +126,32 @@ bool binary_search(span rng, const T& value, Compare return std::binary_search(rng.data(), rng.data() + rng.size(), value, comp); } +// sort +template +void sort(span rng) +{ + std::sort(rng.data(), rng.data() + rng.size()); +} + +template +void sort(span rng, Compare comp) +{ + std::sort(rng.data(), rng.data() + rng.size(), comp); +} + +// stable sort +template +void stable_sort(span rng) +{ + std::stable_sort(rng.data(), rng.data() + rng.size()); +} + +template +void stable_sort(span rng, Compare comp) +{ + std::stable_sort(rng.data(), rng.data() + rng.size(), comp); +} + } // namespace gsl #ifdef _MSC_VER