removed sortbytarget function, unused.