Dataframe 0.15 Help

sortBy

Returns DataFrame with rows sorted by one or several columns.

By default, columns are sorted in ascending order with null values going first. Available modifiers:

  • .desc — changes column sort order from ascending to descending

  • .nullsLast — forces null values to be placed at the end of the order

df.sortBy { age } df.sortBy { age and name.firstName.desc() } df.sortBy { weight.nullsLast() }
val age by column<Int>() val weight by column<Int?>() val name by columnGroup() val firstName by name.column<String>() df.sortBy { age } df.sortBy { age and firstName } df.sortBy { weight.nullsLast() }
df.sortBy("age") df.sortBy { "age" and "name"["firstName"].desc() } df.sortBy { "weight".nullsLast() }

sortByDesc

Returns DataFrame sorted by one or several columns in descending order.

df.sortByDesc { age and weight }
val age by column<Int>() val weight by column<Int?>() df.sortByDesc { age and weight }
df.sortByDesc("age", "weight")

sortWith

Returns DataFrame sorted with comparator.

df.sortWith { row1, row2 -> when { row1.age < row2.age -> -1 row1.age > row2.age -> 1 else -> row1.name.firstName.compareTo(row2.name.firstName) } }
Last modified: 09 December 2024