@Override
        public int compare(StreamEvent e1, StreamEvent e2) {
            int comparisonResult;
            for (Object[] listItem : parameterInfo) {
                int[] variablePosition = ((VariableExpressionExecutor) listItem[0]).getPosition();
                Comparable comparableVariable1 = (Comparable) e1.getAttribute(variablePosition);
                Comparable comparableVariable2 = (Comparable) e2.getAttribute(variablePosition);
                comparisonResult = comparableVariable1.compareTo(comparableVariable2);
                if (comparisonResult != 0) {
                    return ((Integer) listItem[1]) * comparisonResult;
                }
            }
            return 0;
        }
Sample Query:
from inputStream#window.sort(5, attribute1, "asc", attribute2, "desc")
select attribute1, attribute2
insert into outputStream;
<p>
Description:
In the example query given, 5 is the size of the window.
The arguments following the size of the window are optional.
If neither "asc" nor "desc" is given for a certain attribute, order defaults to "asc"
modules/siddhi-core/src/main/java/io/siddhi/core/query/processor/stream/window/SortWindowProcessor.java