<commit_before>package org.jetbrains.dokka.base.renderers

import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.Kind
import org.jetbrains.dokka.utilities.DokkaLogger

class DefaultTabSortingStrategy : TabSortingStrategy {
    override fun <T: ContentNode> sort(tabs: Collection<T>): List<T> {
        val tabMap: Map<Kind, MutableList<T>> = mapOf(
            ContentKind.Classlikes to mutableListOf(),
            ContentKind.Constructors to mutableListOf(),
            ContentKind.Functions to mutableListOf(),
            ContentKind.Properties to mutableListOf(),
            ContentKind.Extensions to mutableListOf(),
            ContentKind.Parameters to mutableListOf(),
            ContentKind.Inheritors to mutableListOf(),
            ContentKind.Source to mutableListOf(),
            ContentKind.Sample to mutableListOf(),
            ContentKind.Comment to mutableListOf()
        )
        val unrecognized: MutableList<T> = mutableListOf()
        tabs.forEach {
            tabMap[it.dci.kind]?.add(it) ?: unrecognized.add(it)
        }
        return tabMap.values.flatten() + unrecognized
    }

}<commit_msg>Refactor tab map creation<commit_after>package org.jetbrains.dokka.base.renderers

import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.Kind
import org.jetbrains.dokka.utilities.DokkaLogger

private val kindsOrder = listOf(
    ContentKind.Classlikes,
    ContentKind.Constructors,
    ContentKind.Functions,
    ContentKind.Properties,
    ContentKind.Extensions,
    ContentKind.Parameters,
    ContentKind.Inheritors,
    ContentKind.Source,
    ContentKind.Sample,
    ContentKind.Comment
)

class DefaultTabSortingStrategy : TabSortingStrategy {
    override fun <T: ContentNode> sort(tabs: Collection<T>): List<T> {
        val tabMap: Map<Kind, MutableList<T>> = kindsOrder.asSequence().map { it to mutableListOf<T>() }.toMap()
        val unrecognized: MutableList<T> = mutableListOf()
        tabs.forEach {
            tabMap[it.dci.kind]?.add(it) ?: unrecognized.add(it)
        }
        return tabMap.values.flatten() + unrecognized
    }

}
{'fraction_non_alphanumeric': 0.0999099909990999, 'fraction_numerical': 0.0, 'mean_word_length': 3.2915057915057915, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373343', 'n_tokens_mistral': 688, 'n_tokens_neox': 668, 'n_words': 121}