Sorting by private field inverts ascending and descending options

We have a site where we have records of people and the Title is fist name last name (John Smith). But we want to add the ability to sort by last name. I created an IsVersionOf field and put just the last name in the field. Since we didn’t want this field to display I marked the field as private.

In the browse.phtml file I then added the label/value pair to the field sort menu.

However, when I sort by that field, it does the exact opposite of any other field. So Ascending is Z-A and Descending is A-Z.

If I mark the field as public, then it works just fine. Ascending is A-Z and Descending is Z-A. So the issue is that it is marked as private. But I have no idea as to why it is inverting the sorts.

You’re sure it’s sorting in reverse order, vs. just not sorting by the value at all?

Hide Properties is probably the better choice for just removing a property from view but still having it be used by the public in some way (like for sorting). Private values are handled at a lower level, and are really intended for pieces of information that shouldn’t be accessible at all.

I tested it three times and it was definitely sorting when I toggled between ASC and DESC in the opposite way it was intended.

I’ll look into Hide Properties. Thanks.

Hide Properties was perfect. Thanks for the suggestion!