class School {
    private var database: MutableMap<Int, List<String>> = emptyMap<Int, List<String>>().toMutableMap()
    fun db(): Map<Int, List<String>>{
        return database
    }

    fun sort(): Map<Int, List<String>>{
        val returnDatabase = database.toSortedMap(Comparator<Int>{o1, o2 -> o1 - o2 })
        // Super shitty and hacky but... ehhh
        for (i in returnDatabase.keys){
            returnDatabase.put(i, returnDatabase.getOrDefault(i, emptyList()).sorted())
        }
        return returnDatabase
    }

    fun add(name: String, grade: Int){
        val gradeList: MutableList<String> = this.database.getOrDefault(grade, emptyList<String>()).toMutableList()
        gradeList.add(name)
        this.database.put(grade, gradeList)
    }

    fun grade(grade: Int): List<String>{
        return this.database.getOrDefault(grade, emptyList<String>())
    }

}