public void gen_orderBy(final Map<String, Object> context, final QLSelect select, final PrintWriter out) {
        final Class<?> clazz = (Class<?>) context.get("class");

        if (clazz == null) {
            throw new IllegalArgumentException("context not contains 'class'");
        }

        final QLOrderBy orderBy = select.getOrderBy();
        if (orderBy == null || orderBy.getItems().size() == 0) {
            return;
        }

        String className = clazz.getName();
        className = className.replaceAll("\\$", ".");

        for (QLOrderByItem item : orderBy.getItems()) {
            out.println("		{");
            out.println("			Comparator<" + className + "> comparator = new Comparator<" + className + ">() {");
            out.println("				public int compare(" + className + " a, " + className + " b) {");

            if (item.getMode() == QLOrderByMode.DESC) {
                out.println("					if (" + gen_orderByItem(context, "a", item.getExpr()) + " > "
                            + gen_orderByItem(context, "b", item.getExpr()) + ") {");
                out.println("						return -1;");
                out.println("					}");

                out.println("					if (" + gen_orderByItem(context, "a", item.getExpr()) + " < "
                            + gen_orderByItem(context, "b", item.getExpr()) + ") {");
                out.println("						return 1;");
                out.println("					}");
            } else {
                out.println("					if (" + gen_orderByItem(context, "a", item.getExpr()) + " > "
                            + gen_orderByItem(context, "b", item.getExpr()) + ") {");
                out.println("						return 1;");
                out.println("					}");

                out.println("					if (" + gen_orderByItem(context, "a", item.getExpr()) + " < "
                            + gen_orderByItem(context, "b", item.getExpr()) + ") {");
                out.println("						return -1;");
                out.println("					}");
            }

            out.println("					return 0;");
            out.println("				}");
            out.println("			};");
            out.println("			Collections.sort(" + destCollectionName + ", comparator);");
            out.println("		}");
        }
    }