Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to sort values by domain name (hyerarchically, so last element first) #8594

Open
lapo-luchini opened this issue Mar 25, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@lapo-luchini
Copy link
Contributor

Is your feature request related to a problem? Please describe

When I list hostnames I find that sorting by TLD, then second level domain, etc. is better than raw alphabetical sort, as all hosts in the same sub-domain are close together.

Describe the solution you'd like

Right now I'm doing something like this (kinda works but it's limited):

sort_by_label(
    label_replace(
        {query},
       "inv_instance", "$4.$3.$2.$1",
    "instance", "^([^.]+[.])?([^.]+)[.]([^.]+)[.]([^.]+)[-:].*"),
"inv_instance", "instance")

… if it was JavaScript I would probably sort by fqdn.split('.').reverse().join('.'), maybe a specific new sorting function could be added.

Aliaksandr Valialkin suggested a name like sort_by_label_fqdn(q, "label_name").

Describe alternatives you've considered

No response

Additional information

No response

@lapo-luchini lapo-luchini added the enhancement New feature or request label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant