What is the fastest sorting algorithm for a small number of integers?

后端 未结 12 3288
青春惊慌失措
青春惊慌失措 2021-02-20 18:45

I am wondering what the fastest algorithm would be for this. I have 8 integers between 0 and 3000 and I need to sort them. Although there are only 8 integers, this operation w

12条回答
  •  心在旅途
    2021-02-20 19:10

    Have you profiled your code to show that the sort is a bottleneck? If it isn't a bottleneck, then speeding it up won't buy you much. Sorting eight short integers is pretty fast.

    In general, std::sort() will be faster than anything you can write, unless you are a real sorting guru.

提交回复
热议问题