Sorting by aggregate

I was able to figure it out. I just needed to make sure the DQL query variable had a dollar sign in front of it in both the query function and the filter:

query q($userId: string) {
  var(func: type(User)) @filter(uid($userId)) {
  ...
  }