>>5
You should be putting your highest m numbers in a binary search tree. Then for each number: 1. you insert it in the BST. and 2. remove the (m+1)th smallest element in the tree.
So you would get a O(n log m) algorithm instead of a O(nm) algorithm, where n is the number of elements in the array, and m is from the mth largest element that you want.