Details
Description
In EntityQuery the method getFieldList() uses the class variable distinct to decide if the list of genericValues should be stored in a set to eliminate duplicate values. This variable is set by the function distinct() and normally it should only be used for the sql statement. But here the flag gets mistreated since, if the list of values was ordered because of orderBy(), the order of values gets lost by putting them into a set. To summarize, the following statement:
....orderBy("...").dinstinct().getFieldLlist("...");
does not produce an ordered list.
Replacing the HashSet by a LinkedHashSet fixes this issue.