Make into vemsort function.