title: How can I completely sort arbitrary JSON using jq?
body: <p>I want to diff two JSON text files.  Unfortunately they're constructed in arbitrary order, so I get diffs when they're semantically identical.  I'd like to use jq (or whatever) to sort them in any kind of full order, to eliminate differences due only to element ordering.</p>
  
  <p>--sort-keys solves half the problem, but it doesn't sort arrays.</p>
  
  <p>I'm pretty ignorant of jq and don't know how to write a jq recursive filter that preserves all data; any help would be appreciated.</p>
  
  <p>I realize that line-by-line 'diff' output isn't necessarily the best way to compare two complex objects, but in this case I know the two files are very similar (nearly identical) and line-by-line diffs are fine for my purposes.</p>
  
  <p><a href="https://stackoverflow.com/questions/31930041">Using jq or alternative command line tools to diff JSON files</a> answers a very similar question, but doesn't print the differences.  Also, I want to save the sorted results, so what I really want is just a filter program to sort JSON.</p>