This site requires JavaScript, please enable it in your browser!
Greenfoot back
Abwatts
Abwatts wrote ...

2019/4/10

Sorting Blocks

Abwatts Abwatts

2019/4/10

#
I am trying to sort these blocks using merge sort but I can't think of a way to accomplish that since the blocks are stored inside a list which requires swapping (.set method) to sort it out. (I don't want to use the built-in .sort method since the whole point is to use the sorting algorithm myself) and the merge sort doesn't use any swappings like the bubble sort. Is there a way I can use the merge sort to sort these blocks that are stored inside a list?
Super_Hippo Super_Hippo

2019/4/11

#
The merge sort algorithm basically cuts lists in half and sorts them. You won't be able to implement the algorithm without creating more lists in the process. The Wikipedia article is pretty helpful I would say: https://en.wikipedia.org/wiki/Merge_sort
You need to login to post a reply.