How to sort in this case?

Thank you .
It works.

 x as sum(val(p))
{
  var(func: has(starring)) {
    starring {  # Gives you booklist.
       haveBook (first: 1, orderdesc: price) {
         p as title # Maps from book -> price. Should only have 1 entry.
       }
       x as sum(val(p))  # Maps from booklist -> price.
    }
  }

  lists(func: uid(x), orderasc: val(x)) {
    haveBook { title, price }  # Print the books in the booklist.
  }
}

and

{
  var(func: has(starring)) {
    starring {  # Gives you booklist.
       haveBook (first: 1, orderdesc: price) {
         p as price # Maps from book -> price. Should only have 1 entry.
       }
       x as sum(val(p))  # Maps from booklist -> price.
    }
  }

  lists(func: uid(x), orderasc: val(x)) {
    haveBook { title, price }  # Print the books in the booklist.
  }
}

both works.