if(fetchSpecification != null && fetchSpecification.sortOrderings().count() > 0) {
fetchSpecification = (EOFetchSpecification) fetchSpecification.clone();
NSMutableArray sortOrderings = new NSMutableArray(fetchSpecification.sortOrderings().count());
for (Enumeration enumerator = fetchSpecification.sortOrderings().objectEnumerator(); enumerator.hasMoreElements();) {
EOSortOrdering item = (EOSortOrdering) enumerator.nextElement();
String key = item.key();
NSArray path = NSArray.componentsSeparatedByString(key, ".");
EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, fetchSpecification.entityName());
String attributeName = (String) path.lastObject();
String prefix = "";
if(path.count() > 1) {