List -> Compare, Sort
Monkey Forums/Monkey Programming/List -> Compare, Sort
| ||
Hey, i would like to extend the list to make my own sortable list. But the problem is that i dont know what Compare need to do at all for that: ---------------------------------------------- Method Compare : Int ( lhs:T, rhs:T ) This method is used by the Sort method to compare elements. By default, this methods simply generates a runtime error. Extending classes should implement this method if they want to support Sort. ---------------------------------------------- Is not very much information... I think that lhs and rhs are the 2 values that should be compared to each other, but what do i need to return? it want a Int as return, but what? oO 0 or 1, for wich one is the one that should be up? 1 or 2? |
| ||
If I'm not wrong, -1 if the first param is smaller, 0 ir are equal and 1 if the second is smaller |
| ||
Google is your friend: ;) http://monkeycoder.co.nz/Community/posts.php?topic=1257 |
| ||
ty^^ i not found that via google or forum search :( |
| ||
This was my search query on google: site:monkeycoder.co.nz compare sort |