From 9300a4b0ba649af225f6c005dbfe70aa9c9e8c0e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 18 Dec 2022 12:42:23 +0000 Subject: Helper to sort glm::vecs by a specific axis --- lib/sorting.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/sorting.hpp b/lib/sorting.hpp index 0604aaf..777de00 100644 --- a/lib/sorting.hpp +++ b/lib/sorting.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include template struct PtrSorter { @@ -28,3 +29,21 @@ template struct PtrMemberSorter : public PtrSorter { return (*a).*M < b; } }; + +struct CompareBy { + glm::length_t index; + + template + auto + operator()(const T & a, const T & b) const + { + return get(a) < get(b); + } + + template + auto + get(const T & a) const + { + return a[index]; + } +}; -- cgit v1.2.3