if (_localSortKey()!=null && _localSortKey().length()>0) ERXArrayUtilities.sortArrayWithKey(aSortedArray, _localSortKey());
ERXArrayUtilities.sortArrayWithKey(aSortedArray, _localSortKey());
    public NSArray theList() {        NSMutableArray aSortedArray;        NSArray anUnsortedArray;        if (_privateList()==null ) {            EODataSource aDataSource = _localDataSource();            // Need to make sure that the eos are in the right editingContext.	    // ak: We get a dictionary as object if we use this in a query,	    // so we have to check....	    EOEditingContext ec;	    	    if(_sourceObject instanceof EOEnterpriseObject && ((EOEnterpriseObject)_sourceObject).editingContext() != null)		ec = ((EOEnterpriseObject)_sourceObject).editingContext();	    else		ec = session().defaultEditingContext();	    	    anUnsortedArray = ERXEOControlUtilities.localInstancesOfObjects(ec, aDataSource.fetchObjects());            // 81398 sort contents            aSortedArray = new NSMutableArray(anUnsortedArray);            /* WO5                try {                    _RelationshipSupport._sortEOsUsingSingleKey(aSortedArray, _localSortKey());                } catch (NSComparator.ComparisonException e) {                    throw new NSForwardException(e);                }            */            if (_localSortKey()!=null && _localSortKey().length()>0)                ERXArrayUtilities.sortArrayWithKey(aSortedArray, _localSortKey());            // if there is a value on the EO, then we need to make sure that the list's EOs are in the same EC            // otherwise the popup selection will be wrong (will default to the first element)            // this happens for ex on a wizard page with a popup. Select sth in the popup, but leave a mandatory field blank            // click next --> the page comes back with the error, but the popup lost the selection you made            if (_localSourceObject() instanceof EOEnterpriseObject &&                ((EOEnterpriseObject)_localSourceObject()).valueForKeyPath(_localRelationshipKey()) != null) {                NSMutableArray localArray= new NSMutableArray();                EOEnterpriseObject eo;                ec = ((EOEnterpriseObject)_localSourceObject()).editingContext();                for (Enumeration e = aSortedArray.objectEnumerator(); e.hasMoreElements();) {                    eo = (EOEnterpriseObject)e.nextElement();                    localArray.addObject((ec != eo.editingContext() && ERXEOControlUtilities.localInstanceOfObject(ec, eo) != null ?                                          ERXEOControlUtilities.localInstanceOfObject(ec, eo) : eo));                }                aSortedArray=localArray;            }                        // dt: we also must ensure that the value on the EO is in this list. This may not be the case if            // one just created a new relationship in a childEc. Therefore we also must set _privateList to null            // in awake, caching cannot work here            if (_localSourceObject() instanceof EOEnterpriseObject) {                EOEnterpriseObject lso = (EOEnterpriseObject)_localSourceObject();                EOEnterpriseObject relObject = (EOEnterpriseObject)lso.valueForKeyPath(_localRelationshipKey());                if (relObject != null) {                    if (!aSortedArray.containsObject(relObject)) {                        aSortedArray.addObject(relObject);                        log.info("adding missing relationship object to list "+relObject);                        if (_localSortKey()!=null && _localSortKey().length() > 0) {                            ERXArrayUtilities.sortArrayWithKey(aSortedArray, _localSortKey());                        }                    }                }            }                        if (!_localIsMandatory()) {                if(noSelectionString() != null)                    aSortedArray.insertObjectAtIndex(noSelectionString(), 0);            }            set_privateList(aSortedArray);        }        return _privateList();    }