Here's an implementation of Merge Sort in C#:
main.cs1176 chars50 lines
To use this implementation, simply call the MergeSort
method, passing in the array you wish to sort, like so:
main.cs76 chars3 lines
Afterwards, the arrayToSort
will be sorted in ascending order.
Note: This implementation works for arrays of any length, but is not optimized for very large arrays. If you need to sort large arrays, consider using an iterative implementation or a parallel version.
gistlibby LogSnag