I am using C# in Unity and so would like to avoid any memory allocations when sorting a list. When I call List<int>.Sort() under the hood it seems to call Array.Sort() and ArraySortHelper.Sort() which allocates the memory according to the Unity profiler. To avoid this I have resorted to writing my own allocation-free generic quicksort algorithm, but I'm so surprised that this is necessary for something so basic as sorting a List of ints, that I thought I would ask if anybody can point me to some simple memory allocation free method of sorting a list in the standard library.
EDIT
I am aware of the following question: Is there a way to sort arrays without allocating any memory?. My requirements are quite different. I do not have any issues with Keys being slow to compute (it is specifically a List of type int) and I cannot use the SortedSet suggested in the comments of that question as elements may have duplicates. I am not concerned about the performance of the algorithm in particular, I would just like to find some standard library implementation that is readily available that can sort a List of ints without any resulting memory allocations. It does not have to be a method on the class itself, I have coded my own static generic quicksort which works fine, but I hope to find something like it that has already been implemented somewhere in standard libraries because it feels like such a basic thing that I should not have to maintain my own function to complete that task.
Many thanks!