added sorting function + protocol + default implementation + tests