package org.fossify.musicplayer.extensions fun MutableList.sortSafely(comparator: Comparator) { try { sortWith(comparator) } catch (ignored: Exception) { } } fun MutableList.move(currentIndex: Int, newIndex: Int) { val itemToMove = removeAt(currentIndex) if (currentIndex > newIndex) { add(newIndex, itemToMove) } else { add(newIndex - 1, itemToMove) } }