/* 
 * Script decompiled by jagdecs2 v3.2
 * Decompiler opts:
 * --------------
 * t1LocalAnalyzer:true
 * t2LocalAnalyzer:true
 * beautifier:true
 * --------------
 * Made by mgi125 ;)
 */


void script_1842(int a0,int a1,int a2) {
	int v4 = cs2method_10968(cs2method_10060(a1, a0), 2);
	int v2 = globalarray_0[v4];
	globalarray_0[v4] = globalarray_0[a0];
	globalarray_0[a0] = v2;
	for (int v5 = a1, int v1 = a1, int v3 = 0, int v0 = -1, int v6 = -1; v1 < a0; v1 = cs2method_10060(v1, 1)) {
		int v8 = idx17mapData('i', 'J', 1805, globalarray_0[v1]);
		int v7 = idx17mapData('i', 'J', 1805, v2);
		if (cs2method_10846(cs2method_10181(idx22mapAttribute(v8, 596)), cs2method_10181(idx22mapAttribute(v7, 596))) < cs2method_10147(v1, 1)) {
			int v7 = globalarray_0[v1];
			globalarray_0[v1] = globalarray_0[v5];
			globalarray_0[v5] = v7;
			v5 = cs2method_10060(v5, 1);
		}
	}
	globalarray_0[a0] = globalarray_0[v5];
	globalarray_0[v5] = v2;
	if (a1 < cs2method_10461(v5, 1)) {
		script_1842(0, a1, cs2method_10461(v5, 1));
	}
	if (cs2method_10060(v5, 1) < a0) {
		script_1842(0, cs2method_10060(v5, 1), a0);
	}
	return;
}
