Sorting is a big topic and unless using readymade methods like Array.Sort,
List<T>.Sort
, linq OrderBy
, etc. you are better to decide first on an algorithm you are trying to implement and sticking to its pseudo-code as close as you can. E.g. bubble sort.