Your Matter and Contact CSV exports will include data from all of your Custom Fields which will allow you to sort your exports and report on any criteria.
To export your Matters, refer to the instructions HERE.
To export your Contacts, refer to the instructions HERE.
When viewing an exported Matter or Contact CSV in Excel or other spreadsheet application, you will see columns named for each of your Custom Fields along with the information that you have entered on your Matters or Contact cards.
For information on how to filter and sort your CSV exports in Excel, see the following articles: