freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany (JIRA)" <>
Subject [jira] [Commented] (FREEMARKER-62) ?sort_by to accept Iterable
Date Tue, 11 Jul 2017 18:43:00 GMT


Daniel Dekany commented on FREEMARKER-62:

It works with arrays and anything that's wrapped as {{TemplateSequenceModel}}, but I got the
point. {{Iterator}}-s aren't wrapped as {{TemplateSequenceModel}}-s. Well, I guess to sort
something you need to copy it into an array (or {{List}}) and do an in place sort anyway.
So why not, I guess. (Though it will be funny that you can't call, say, {{?size}} on the thing
before sorting (because it's not a sequence), but after sorting you magically can.)

> ?sort_by to accept Iterable
> ---------------------------
>                 Key: FREEMARKER-62
>                 URL:
>             Project: Apache Freemarker
>          Issue Type: Improvement
>          Components: engine
>    Affects Versions: 2.3.26-incubating
>            Reporter: Ondra Žižka
>            Priority: Minor
> Currently, {{?sort_by()}} only accepts a {{List}}.
> It's not complicated to create an {{iteratorToList() FreemarkerMethod}}, though.
> So this is a suggestion to make {{?sort_by}} accept an {{Iterable}}, and if it detects
it was called for Iterable and not a List, it would create the sorted list. It could use heapsort

This message was sent by Atlassian JIRA

View raw message