When to use either the word "by" or "depending on" to classify something?
As a rough guide, in the Corpus of Contemporary American English there are 122 hits for the string 'BE SORT by' and zero for 'BE SORT depending on'. A similar comparison in the WEB corpus yields 6,522 hits for the former and 6 for the latter.
This would seem to indicate that the by version is by far the more common, though the depending on version does not strike me as unintelligible in the following example.
All cork stoppers are visually sorted depending on their quality grade. (WidgetCo)
It does however leave open the interpretation of these stoppers are sorted if they meet the required quality grade OR these stoppers are sorted in different ways depending on their quality grade.
The by choice avoids any ambiguity, and is the natural choice. That being said, it seems unlikely the depending on version would be misinterpreted or found jarring in context.