public static int[] sort(LinearSparseVector sv) {
		HashMap<Integer, Float> map = new HashMap<Integer, Float>();

		Iterator<Integer> it = sv.iterator();
		while (it.hasNext()) {
			int id = it.next();
			float val = sv.get(id);
			map.put(id, Math.abs(val));
		}
		it = null;

		ArrayList<Map.Entry<Integer, Float>> list = new ArrayList<Map.Entry<Integer, Float>>(
				map.entrySet());

		Collections.sort(list, new Comparator<Map.Entry<Integer, Float>>() {
			@Override
			public int compare(Entry<Integer, Float> o1,
					Entry<Integer, Float> o2) {

				if (o2.getValue() > o1.getValue()) {
					return 1;
				} else if (o1.getValue() > o2.getValue()) {
					return -1;
				} else {
					return 0;
				}
			}
		});
		int[] idx = new int[list.size()];
		for (int i = 0; i < list.size(); i++) {
			idx[i] = list.get(i).getKey();
		}
		return idx;

	}
public static int [ ] sort ( LinearSparseVector sv ) { HashMap < Integer , Float > map = new HashMap < Integer , Float > ( ) ; Iterator < Integer > it = sv . iterator ( ) ; while ( it . hasNext ( ) ) { int id = it . next ( ) ; float val = sv . get ( id ) ; map . put ( id , Math . abs ( val ) ) ; } it = null ; ArrayList < Map . Entry < Integer , Float > > list = new ArrayList < Map . Entry < Integer , Float > > ( map . entrySet ( ) ) ; Collections . sort ( list , new Comparator < Map . Entry < Integer , Float > > ( ) { @ Override public int compare ( Entry < Integer , Float > o1 , Entry < Integer , Float > o2 ) { if ( o2 . getValue ( ) > o1 . getValue ( ) ) { return 1 ; } else if ( o1 . getValue ( ) > o2 . getValue ( ) ) { return - 1 ; } else { return 0 ; } } } ) ; int [ ] idx = new int [ list . size ( ) ] ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { idx [ i ] = list . get ( i ) . getKey ( ) ; } return idx ; }
对数组的绝对值由大到小排序，返回调整后元素对于的原始下标

@param sv
待排序数组
@return 原始下标