From 1378c40a2c55a76663945a9c798c35cfe65a04e9 Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sat, 24 Oct 2015 02:38:44 +0100 Subject: [PATCH] fixed toc items order --- jni/NativeFormats/JavaNativeFormatPlugin.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jni/NativeFormats/JavaNativeFormatPlugin.cpp b/jni/NativeFormats/JavaNativeFormatPlugin.cpp index 4e82c1e8f..a0b57903a 100644 --- a/jni/NativeFormats/JavaNativeFormatPlugin.cpp +++ b/jni/NativeFormats/JavaNativeFormatPlugin.cpp @@ -237,8 +237,13 @@ static jobject createTextModel(JNIEnv *env, jobject javaModel, ZLTextModel &mode return env->PopLocalFrame(textModel); } +static bool ct_compare(const shared_ptr &first, const shared_ptr &second) { + return first->reference() < second->reference(); +} + static void initTOC(JNIEnv *env, jobject javaModel, const ContentsTree &tree) { - const std::vector > &children = tree.children(); + std::vector > children = tree.children(); + std::sort(children.begin(), children.end(), ct_compare); for (std::vector >::const_iterator it = children.begin(); it != children.end(); ++it) { const ContentsTree &child = **it; JString text(env, child.text());