nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Issues showing sorted personList in UI #242

Closed shenchenzizoe closed 1 year ago

shenchenzizoe commented 1 year ago

Have anyone tried to implement a sort function for the tp? For our team project, we plan to add a sort function so that contacts can be listed in order (for example, by name alphabetically). However, the original AB3 is using an ObservableList to manage Persons, which can not be modified. The current "list" and "find" functions are achieved by using a filteredList, which is a subset of the ObservableList. We can set a predicate to filter out the result we want, but the order of Persons can not be changed. We tried to pass a new sortedList into that filteredList, which is finally being proceeded to UI. Nevertheless, it does not work as it seems that the filteredList must be part of the ObservableList, passing other values into it causes issues to ModelManager and affects other functions like "find". Does anyone have suggestions about how to solve this? Should we change the whole data structure of the ObservableList? Should we write new UI functions so we can pass other lists into it (because for now AB3 only uses the the single ObservableList for UI)? Would really appreciate any relative guidance and suggestions!:heart:

shenchenzizoe commented 1 year ago

Solved this issue for the current stage. The method I implemented is described in the following link: https://github.com/AY2223S2-CS2103T-W11-4/tp/issues/49

damithc commented 1 year ago

Thanks for sharing your solution, @shenchenzizoe