Remarks on custom Java class based field:
This is a small section of a large article custom sorting in Solr using external field written to sort Solr documents based on custom field comparator.
Remarks on custom field created from existing Solr fields:
Apache has created a detailed documentation on this topic - Understanding Analyzers, Tokenizers, and Filters.