Improve note sorting for bug 987328