-
Notifications
You must be signed in to change notification settings - Fork 0
Sorting_en
You can sort objects that implements Comparable using _org.sofof.command.sorter.Sorter_ objects. This interface implementations offer very helpful sorting features such as sorting Student objects based on their marks or their names using ObjectSorter. This example shows how writing an expression to the ObjectSorter can help you sort objects quickly: <\p> ```java import org.sofof.bean.Student; import org.sofof.command.Select; import org.sofof.command.sorter.ObjectSorter; import org.sofof.command.sorter.Order; import org.sofof.permission.User; import java.io.File;
public class Documentation { public static void main(String[] args) throws SofofException { Database.createDatabase(new File("sofof")); Server s = new Server(new File("sofof"), 6969, false); s.getUsers().add(new User("rami", "secret")); s.startUp(); try (Session sess = SessionManager.startSession("sofof:localhost:6969", new User("rami", "secret"), false)) { session.query(new Select(Student.class).from("students").sort(new ObjectSorter("#getName()", Order.Aescending))); } } }
<p>
Note that there is another paramter in the ObjectSorter constructor. This parameter determine the sorting order.
You can sort objects by different priorities by calling _after(Sorter)_ on the higher priority sorter and passing the lower priority sorter to the method.
<\p>