Skip to Main Content
Feature Request FR-3491
Product Area Page Components
Status ROADMAP

6 Voters

List of Values custom group sort order

gerald.weber Public
· Nov 14 2023

Idea Summary

Let a List of Values have a custom defined sort order for the group, not just the 4 defaults Ascending/Descending + Nulls First/Last.

Use Case

It's currently not possible to sort the groups in the lov in a specific custom order - except when you put a number or letter in front of the group's name.

E.g.

desired order:

Group C

Group H

Group B

Group A

you have to name the groups:

1 Group C

2 Group H

3 Group B

4 Group A

This is currently on the roadmap for a future release of Oracle APEX.

Comments

Comments

  • jayson hanes Admin OP 2.2 years ago

    Typically this is handled by having a sequence column or similar.

  • jan.kvetina OP 2.1 years ago

    To sort the groups I added a number of spaces infront of each. They are not rendered by the browser.

    LPAD(' ', ROW_NUMBER() OVER (ORDER BY {SORT}), ' ') || {VISIBLE_NAME} AS group_name
    
  • jayson hanes Admin OP 2.1 years ago

    I'm not sure what the challenge with this is? Just add a sort order based on a column that has a number for the order by

  • jan.kvetina OP 2.1 years ago

    That works for values, but not for groups. Try LOV with groups, they are sorted A-Z and you cant change that…

  • jayson hanes Admin OP 2.1 years ago

    huh? 

    1

    2

    2.1

    2.2

    3

    10

    100.1

    100.2….

    done

  • jan.kvetina OP 2.1 years ago

    How would you show Meaning before Color if it doesnt starts with a number?

  • jayson hanes Admin OP 2.1 years ago

    So you're showing indentation there, but still, that sequence column would be ordered by in the List of Values query, and this would be handled easily. The indentation would be a case/when in front of the name (not a whole number) etc..

  • jan.kvetina OP 2.1 years ago

    But the Meaning + Color (the group names) are not part of the query as rows, but as columns. So you cant assign your sequence to the groups. Only to group members. And then you are back to the issue that you cant sort groups.

  • jan.kvetina OP 2.1 years ago

    Here you go, can you show me how would you sort the groups based on this query?

    WITH t (group_, name_, value_) AS (
        SELECT 'Color',     'Green',        10 FROM DUAL UNION ALL
        SELECT 'Color',     'Dark Green',   20 FROM DUAL UNION ALL
        SELECT 'Meaning',   'Feature',      30 FROM DUAL UNION ALL
        SELECT 'Meaning',   'Delighter',    40 FROM DUAL
    )
    SELECT * FROM t;
    
  • jayson hanes Admin OP 2.1 years ago

    what am I missing? (or add another column of seq_ similar)

    WITH t (group_, name_, value_) AS (
       SELECT 'Color',     'Green',        10  FROM DUAL UNION ALL
       SELECT 'Color',     'Dark Green',   20 FROM DUAL UNION ALL
       SELECT 'Meaning',   'Feature',      30 FROM DUAL UNION ALL
       SELECT 'Meaning',   'Delighter',    40 FROM DUAL
    )
    SELECT count(*), group_, name_, value_  FROM t
    group by  group_, name_, value_
    order by value_
    

  • jan.kvetina OP 2.1 years ago

    Now do this as a source for LOV and try to sort groups as on the screen above. Meaning first, then Color. Try it.

  • jayson hanes Admin OP 2.1 years ago

    Thanks for the explanation. I concede that it should be easier to achieve what you're after.