Skip to content

Instantly share code, notes, and snippets.

@rygorous
Last active April 25, 2022 20:55
Show Gist options
  • Save rygorous/7736f58738a1b8343244928df3502dea to your computer and use it in GitHub Desktop.
Save rygorous/7736f58738a1b8343244928df3502dea to your computer and use it in GitHub Desktop.
Mwahaha
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <algorithm>
int main()
{
constexpr size_t count = 20;
float vals[count] =
{
1.f, 2.f, 3.f, 4.f, NAN,
1.f, 2.f, 3.f, 4.f, NAN,
1.f, 2.f, 3.f, 4.f, NAN,
1.f, 2.f, 3.f, 4.f, NAN,
};
//std::sort(vals, vals + count);
//std::stable_sort(vals, vals + count);
std::partial_sort(vals, vals + count, vals + count);
for (size_t i = 0; i < count; ++i)
printf("[%2d] %f\n", (int)i, vals[i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment