Added sort in Java template.