custom sort_by method by Boris