sparqlGraphLibrary/src/main/java/com/ge/research/semtk/ontologyTools/OntologyInfo.java
private void sortPaths(ArrayList<OntologyPath> list) {
		boolean swap;
		// for each element in list
		for (int i=1; i < list.size(); i++) {
			int insertAt = i;
			// look at the previous elements
			for (int j=i-1; j >= 0; j--) {
				// if list item is path with same length
				if (list.get(j).getLength() == list.get(i).getLength()) {
					swap = true;
					int score = 0;
					// scoring system: equal is 0, subclass is a +, superclass is a -, none is automatic -100 fail
					for (int k=0; k < list.get(i).getLength() && swap==true; k++) {
						Triple triple_ik = list.get(i).getTriple(k);
						String subi = triple_ik.getSubject();
						String predi = triple_ik.getPredicate();
						String obji = triple_ik.getObject();
						
						Triple triple_jk = list.get(j).getTriple(k);
						String subj = triple_jk.getSubject();
						String predj = triple_jk.getPredicate();
						String objj = triple_jk.getObject();
						
						if (subj.equals(subi)) {
							//zero
						} else if ( this.isSubclassOf(subi, subj)) {
							score += 1;
						} else if ( this.isSubclassOf(subj, subi)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
						if (predj.equals(predi)) {
							//zero
						} else if (this.isSubPropOf(predi, predj)) {
							score += 1;
						} else if ( this.isSubPropOf(predj, predi)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
						if (objj.equals(obji)) {
							//zero
						} else if (this.isSubclassOf(obji, objj)) {
							score += 1;
						} else if (this.isSubclassOf(objj, obji)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
					}
					
					// if there are more subclasses then superclasses in the path, move the item ahead
					if (score > 0) {
						insertAt = j;
					} 
				} else {
					break;
				}
				
			}
			// if any previous items are moveable, do it
			if (insertAt < i) {
				OntologyPath tmp = list.get(i);
				list.remove(i);
				list.add(insertAt, tmp);
			}
		}
	}
/**
	 * Presuming the findAllPaths algorithm already sorts shortest to longest
	 * and puts adjacent subclasses,subproperties in adjacent positions...
	 * Do the remaining sort of putting the subclasses/subproperties first.
	 * In other words, each grouping is sorted most-specific first.
	 * 
	 * @param list
	 */
Presuming the findAllPaths algorithm already sorts shortest to longest
and puts adjacent subclasses,subproperties in adjacent positions
Do the remaining sort of putting the subclasses/subproperties first.
In other words, each grouping is sorted most-specific first.

@param list
Presuming the findAllPaths algorithm already sorts shortest to longest and puts adjacent subclasses subproperties in adjacent positions Do the remaining sort of putting the subclasses / subproperties first . In other words each grouping is sorted most - specific first . @param list
private void sortPaths(ArrayList<OntologyPath> list) {
		boolean swap;
		for (int i=1; i < list.size(); i++) {
			int insertAt = i;
			for (int j=i-1; j >= 0; j--) {
				if (list.get(j).getLength() == list.get(i).getLength()) {
					swap = true;
					int score = 0;
					for (int k=0; k < list.get(i).getLength() && swap==true; k++) {
						Triple triple_ik = list.get(i).getTriple(k);
						String subi = triple_ik.getSubject();
						String predi = triple_ik.getPredicate();
						String obji = triple_ik.getObject();
						Triple triple_jk = list.get(j).getTriple(k);
						String subj = triple_jk.getSubject();
						String predj = triple_jk.getPredicate();
						String objj = triple_jk.getObject();
						if (subj.equals(subi)) {
						} else if ( this.isSubclassOf(subi, subj)) {
							score += 1;
						} else if ( this.isSubclassOf(subj, subi)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
						if (predj.equals(predi)) {
						} else if (this.isSubPropOf(predi, predj)) {
							score += 1;
						} else if ( this.isSubPropOf(predj, predi)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
						if (objj.equals(obji)) {
						} else if (this.isSubclassOf(obji, objj)) {
							score += 1;
						} else if (this.isSubclassOf(objj, obji)) {
							score -= 1;
						} else {
							score = -100;
							break;
						}
					}
					if (score > 0) {
						insertAt = j;
					} 
				} else {
					break;
				}
			}
			if (insertAt < i) {
				OntologyPath tmp = list.get(i);
				list.remove(i);
				list.add(insertAt, tmp);
			}
		}
	}
private void sortPaths ( ArrayList < OntologyPath > list ) { boolean swap ; for ( int i = 1 ; i < list . size ( ) ; i ++ ) { int insertAt = i ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( list . get ( j ) . getLength ( ) == list . get ( i ) . getLength ( ) ) { swap = true ; int score = 0 ; for ( int k = 0 ; k < list . get ( i ) . getLength ( ) && swap == true ; k ++ ) { Triple triple_ik = list . get ( i ) . getTriple ( k ) ; String subi = triple_ik . getSubject ( ) ; String predi = triple_ik . getPredicate ( ) ; String obji = triple_ik . getObject ( ) ; Triple triple_jk = list . get ( j ) . getTriple ( k ) ; String subj = triple_jk . getSubject ( ) ; String predj = triple_jk . getPredicate ( ) ; String objj = triple_jk . getObject ( ) ; if ( subj . equals ( subi ) ) { } else if ( this . isSubclassOf ( subi , subj ) ) { score += 1 ; } else if ( this . isSubclassOf ( subj , subi ) ) { score -= 1 ; } else { score = - 100 ; break ; } if ( predj . equals ( predi ) ) { } else if ( this . isSubPropOf ( predi , predj ) ) { score += 1 ; } else if ( this . isSubPropOf ( predj , predi ) ) { score -= 1 ; } else { score = - 100 ; break ; } if ( objj . equals ( obji ) ) { } else if ( this . isSubclassOf ( obji , objj ) ) { score += 1 ; } else if ( this . isSubclassOf ( objj , obji ) ) { score -= 1 ; } else { score = - 100 ; break ; } } if ( score > 0 ) { insertAt = j ; } } else { break ; } } if ( insertAt < i ) { OntologyPath tmp = list . get ( i ) ; list . remove ( i ) ; list . add ( insertAt , tmp ) ; } } }
Presuming the findAllPaths algorithm already sorts shortest to longest
 and puts adjacent subclasses,subproperties in adjacent positions...
 Do the remaining sort of putting the subclasses/subproperties first.
Presuming the findAllPaths algorithm already sorts shortest to longest and puts adjacent subclasses subproperties in adjacent positions ... Do the remaining sort of putting the subclasses / subproperties first .
// for each element in list // look at the previous elements // if list item is path with same length // scoring system: equal is 0, subclass is a +, superclass is a -, none is automatic -100 fail //zero //zero //zero // if there are more subclasses then superclasses in the path, move the item ahead // if any previous items are moveable, do it