Added switch collection sorting (needs testing).