public static void sort(String f1, String f2) throws FileNotFoundException, IOException {
		RandomAccessFile a = new RandomAccessFile(f1, "r");
		RandomAccessFile a2 = new RandomAccessFile(f1, "rw");
		RandomAccessFile b = new RandomAccessFile(f2, "rw");
		DataOutputStream dosb;
		DataOutputStream dosa;
		DataInputStream dis;
		long length = a.length()/4;
		int bin;
		long off;
		long mem = Runtime.getRuntime().totalMemory();
		//int memdiv = (int)(mem/16);
		//int memdiv = 655360;
		int memdiv = 8192;
		
		for (int i = 0; i<31; i++) {
			bin = 1<<i;
			dosb = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(b.getFD()), memdiv));
			dosa = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(a2.getFD()), memdiv));
			dis = new DataInputStream(new BufferedInputStream(new FileInputStream(a.getFD()), memdiv));
			for (int j = 0; j<length; j++) {
				int temp = dis.readInt();
				if ((temp&bin) == 0) {
					dosa.writeInt(temp);
				} else {
					dosb.writeInt(temp);
				}
			}
			dosb.flush();
			
			off = b.getFilePointer()/4;
			b.seek(0);
			dis = new DataInputStream(new BufferedInputStream(new FileInputStream(b.getFD()), memdiv));
			for (long j = 0; j<off; j++) {
				//System.out.println(dis.readInt());
				dosa.writeInt(dis.readInt());
			}
			dosa.flush();
			a.seek(0);
			a2.seek(0);
			b.seek(0);
		}
		dosb = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(b.getFD()), memdiv));
		dosa = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(a2.getFD()), memdiv));
		dis = new DataInputStream(new BufferedInputStream(new FileInputStream(a.getFD()), memdiv));
		for (int j = 0; j<length; j++) {
			int temp = dis.readInt();
			if (temp>0) {
				dosb.writeInt(temp);
			} else {
				dosa.writeInt(temp);
			}
		}
		dosb.flush();
		
		off = b.getFilePointer()/4;
		b.seek(0);
		dis = new DataInputStream(new BufferedInputStream(new FileInputStream(b.getFD()), memdiv));
		for (long j = 0; j<off; j++) {
			dosa.writeInt(dis.readInt());
		}
		dosa.flush();
		a.seek(0);
		a2.seek(0);
		b.seek(0);
	}