diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index 82185071..4efd922f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -58,7 +58,7 @@ fun Context.getMessages(threadId: Int): ArrayList { val selection = "${Sms.THREAD_ID} = ?" val selectionArgs = arrayOf(threadId.toString()) - val sortOrder = "${Sms._ID} DESC LIMIT 100" + val sortOrder = "${Sms._ID} LIMIT 100" var messages = ArrayList() queryCursor(uri, projection, selection, selectionArgs, sortOrder, showErrors = true) { cursor -> @@ -84,7 +84,7 @@ fun Context.getMessages(threadId: Int): ArrayList { messages.addAll(getMMS(threadId, sortOrder)) messages = messages.filter { it.participants.isNotEmpty() } - .sortedByDescending { it.date }.toMutableList() as ArrayList + .sortedWith(compareBy { it.date }.thenBy { it.id }).toMutableList() as ArrayList return messages }