Sorting a list
Monkey Forums/Monkey Beginners/Sorting a list
| ||
I'm trying to use the Sort method for a list of Int's and keep coming up with an : Unable to compare items error.Field player1:List<Int> = New List<Int>() ' some code to add items to the list (may contain duplicate values) player1.Sort(True) I'm sure I'm missing something simple here. |
| ||
Use IntList |
| ||
Sorry if this sounds stupid, what do you mean by Use IntList? |
| ||
Read http://www.monkey-x.com/docs/html/Modules_monkey.list_IntList.html You should also look at the Compare function for Lists etc. http://www.monkey-x.com/docs/html/Modules_monkey.list_List.html#Compare |
| ||
IntList http://www.monkey-x.com/docs/html/Modules_monkey.list_IntList.html Compare() is abstract method in List class. You should extend list class to compare (yours) list items or use IntList(), FloatList(), StringList() to build in types. |
| ||
Thank you guys, I didn't quite understand what you were saying. For the benefit of anyone else who runs into this issue, I simply needed to use:Field deck:IntList = New IntList instead of the deck:List = New List |