implement sorting by type