# Sort order with files drop down

**URL:** <https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592>\
**Category:** Get Help\
**Tags:** question\
**Created:** [October 21, 2025, 2:16pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592 "2025-10-21T14:16:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [October 21, 2025, 2:16pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/1 "2025-10-21T14:16:43Z")

</div>

Were using the following code in `/etc/ood/config/apps/dashboard/initializers/ood.rb` with OnDemand 4.0.7

```auto
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name)
    paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}") }
    paths << FavoritePath.new("/work")
  end
end

```

Which produces

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/6/672c2e72a276c10248f3659047921fc1d1182374.png)

It appears `Files` renders the list in Alpha-Numeric order, regardless of the order they are inserted when calling `FavoritePath.new`. My question is, is there a way to force `Home Directory` back to the top of the list, but otherwise keep the list the same as shown. I’ve tried using a non-printable ASCII value for `title:` above 128

```auto
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name)
    paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}", title: 173.chr) }
    paths << FavoritePath.new("/work", title: 173.chr)
  end
end

```

Which correctly sorts, but produces a display artifact because `173.chr` can’t be rendered.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/f/f84a75131963e670c5739e2e5018c4f6ae60b496.png)

I’ve tried other `XXX.chr` values as well as just `title: “”`, but without success. So, I thought I’d ask. Is there a Ruby trick (or just something I missed in the User Guide) I can use to force `Home Directory` back to the top of the `Files` list, regardless of what might be added with `FavoriatePath.new`.

Thanks!

---

<div class="post-metadata">

**Author:** ![travert](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/travert/32/3074_2.png) [@travert](https://discourse.openondemand.org/u/travert)\
**Post date:** [October 30, 2025, 5:24pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/2 "2025-10-30T17:24:30Z")

</div>

Looking at the code for this, I don’t see any sorting even happening so I’m also confused why that is going on, in fact Home Directory is hard coded in the `view` so I’m surprised it’s doing this.

The only thing I can think of is can you see what `projects` returns before you `concat` it to `paths`? It may be the groups cause a sort of some kind and projects is being sorted there due to Linux/Unix reasons of the ouput.

Relevant code:

> <https://github.com/OSC/ondemand/blob/master/apps/dashboard/app/views/files/_favorites.html.erb>

> <https://github.com/OSC/ondemand/blob/2a8426d75d349153d48a50e207a185d8b12fe403/apps/dashboard/app/javascript/files/file_ops.js>

> <https://github.com/OSC/ondemand/blob/2a8426d75d349153d48a50e207a185d8b12fe403/apps/dashboard/app/apps/ood_files_app.rb#L21>

---

<div class="post-metadata">

**Author:** ![bsingleton](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bsingleton/32/3343_2.png) [@bsingleton](https://discourse.openondemand.org/u/bsingleton)\
**Post date:** [October 31, 2025, 9:11pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/3 "2025-10-31T21:11:53Z")

</div>

Wanted to jump in and point out that the navbar items are not generated by the same code as the favorites that show up inside the files app, so the code controlling this is

> <https://github.com/OSC/ondemand/blob/3014bc3abf03d5d1e6b184dd0a762a2c2a036230/apps/dashboard/app/apps/ood_app.rb#L82-L107>

However this still has the home directory hard coded into the first position, so doesn’t explain the sorting. I also don’t notice this happen on OSC systems also running 4.0.7 and using the same strategies in the initializer.

> <https://github.com/OSC/osc-ood-config/blob/0e47f2b6192d020734d6cc358effc6391f03ce2a/ondemand.osc.edu/apps/dashboard/initializers/ood.rb#L4-L13>

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bbbf57c84051c910054e794bba2021e7a2c9efe7.png)

and even the non-hardcoded favorite paths remain in the order defined in the initializer. Does this issue also affect the favorites displayed on the right side of the files app?

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 3, 2025, 12:58pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/4 "2025-11-03T12:58:55Z")

</div>

Thanks for all the feedback. I ended up going with the following in `ood.rb`

```ruby
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name).sort
    paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}", title: "Work") }
    paths << FavoritePath.new("/work", title: "Work")
  end
end

```

Which produces

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/0/0ad2b9d902d471ebd35e5446309071efc99a5e4b.png)

The key thing with the `Home Directory` location in the `Files` drop down being at the top vs somewhere father down the list seems to be, if I exclude the `title` property when calling `FavoritePath.new`. Anytime `title` isn’t defined for a new `FavoritePath` entry, `Home Directory` gets moved below that entry.

So using the following, and explicitly setting `title: “Work”` for all the entries added in the `map`

```ruby
paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}", title: "Work") }

```

`Home Directory` is at the top, as shown above

but using just

```ruby
paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}") }

```

Where `title` isn’t included when `FavoritePath.new` is called, then `Home Directory` ends up below any entries added without a `title` value set. For example, the following

```ruby
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name).sort
    paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}") }
    paths << FavoritePath.new("/work", title: "Work")
  end
end

```

produces

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/d/d94bf1b09b7d524604a72cb9620dfb8baa620dce.png)

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 3, 2025, 1:10pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/5 "2025-11-03T13:10:50Z")

</div>

Also, I tried using `Pathname.new` in place of `FavoritePath.new`, but that resulted in the same

```ruby
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name).sort
    paths.concat projects.map { |p| Pathname.new("/work/#{p.upcase}") }
    paths << FavoritePath.new("/work", title: "Work")
  end
end

```

Produces

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/1/181bc4b2bdd6d11b9b3742d5e6ef95776111b694.png)

So, no idea why it works for you and not me.

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 3, 2025, 1:56pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/6 "2025-11-03T13:56:28Z")

</div>

Playing around with this some more, I noticed the following, this code

```ruby
Rails.application.config.after_initialize do
  OodFilesApp.candidate_favorite_paths.tap do |paths|

    projects = User.new.groups.map(&:name).sort
    paths.concat projects.map { |p| FavoritePath.new("/work/#{p.upcase}") }

    paths << FavoritePath.new("/work")
  end
end

```

Produces

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/4/432c5de1fd7fbf210c87da7b20d63a45f21cb56c.png)

So, things are rendering/ordered correctly (i.e. in the same way that my code does) in the left side list in the file browser, but the `Files` drop down isn’t ordering the same way.

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 5, 2025, 2:24pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/7 "2025-11-05T14:24:53Z")

</div>

I’ve traced the issue to

`./ood/apps/sys/dashboard/app/views/layouts/nav/_group_items.html.erb`

```ruby
<% OodAppGroup.groups_for(apps: group.apps, group_by: :subcategory, sort: group.sort).each_with_index do |g, index| %>
  <%= content_tag(:li, nil, class: ["dropdown-divider"], role: "separator") if index > 0 %>
  <%= content_tag(:li, g.title, class: ["dropdown-header"]) unless g.title.empty? %>
  <% g.apps.each do |app| %>
    <% app.links.each do |link| %>
      <li role="none">
        <%=
          link_to(
            link.url.to_s,
            title: link.title,
            class: "dropdown-item",
            target: link.new_tab? ? "_blank" : nil,
            aria: ({ current: ('page' if (current_page?(link.url))) }),
            role: 'menuitem',
            data: link.data
          ) do
        %>
          <%= icon_tag(link.icon_uri) unless link.icon_uri.to_s.blank? %> <%= link.title %>
          <% if link.subtitle.present? %>
            <%= content_tag(:small, link.subtitle, class: 'visible-xs-block visible-sm-inline visible-md-inline visible-lg-inline ms-2') %>
          <% end %>
        <% end %>
      </li>
    <% end %>
  <% end %>
<% end %>

```

Specifically, the first line where its setting `sort: group.sort`

Looking at `./ood/apps/sys/dashboard/app/apps/ood_app_group.rb`

```ruby
  def self.groups_for(apps: [], group_by: :category, nav_limit: nil, sort: true)
    groups = apps.group_by { |app|
      app.respond_to?(group_by) ? app.send(group_by) : app.metadata[group_by]
    }.map { |k,v|
      OodAppGroup.new(title: k, apps: sort ? v.sort_by { |a| a.title } : v, nav_limit: nav_limit)
    }
    sort ? groups.sort_by { |g| [g.title.to_s.empty? ? 1 : 0, g.title] } : groups # make sure that the ungroupable app is always last
  end

```

If `sort` comes in not `false`, then its going to sort on `title`, which is against what was said above. However, if I change

```ruby
<% OodAppGroup.groups_for(apps: group.apps, group_by: :subcategory, sort: group.sort).each_with_index do |g, index| %>

```

To

```ruby
<% OodAppGroup.groups_for(apps: group.apps, group_by: :subcategory, sort: false).each_with_index do |g, index| %>

```

Then the `Files` list doesn’t sort and I get the expected results, same as I see in the File Browser left panel

 ![image](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/5/5704d2c8a8c6e400a987b90ae8ab6d2c50592071.png)

Is there a better way to do this? Does changing to `sort: false` like this going cause any unexpected artifacts? I don’t see anything else different in the GUI, but maybe there is a better way to do this that doesn’t require a change to core ERB code file.

Thanks!

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 5, 2025, 3:15pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/8 "2025-11-05T15:15:18Z")

</div>

For anyone else’s benefit who might stumble across this post in the future.

Following standard OOD procedures for these kinds of changes, I copied `/var/www/ood/apps/sys/dashboard/app/views/layouts/nav/_group_items.html.erb` to `/etc/ood/config/apps/dashboard/views/layouts/nav/_group_items.html.erb` and modified the `_group_items.html.erb` file to

```ruby
<% OodAppGroup.groups_for(apps: group.apps, group_by: :subcategory, sort: false).each_with_index do |g, index| %>
  <%= content_tag(:li, nil, class: ["dropdown-divider"], role: "separator") if index > 0 %>
  <%= content_tag(:li, g.title, class: ["dropdown-header"]) unless g.title.empty? %>
  <% g.apps.each do |app| %>
    <% app.links.each do |link| %>
      <li role="none">
        <%=
          link_to(
            link.url.to_s,
            title: link.title,
            class: "dropdown-item",
            target: link.new_tab? ? "_blank" : nil,
            aria: ({ current: ('page' if (current_page?(link.url))) }),
            role: 'menuitem',
            data: link.data
          ) do
        %>
          <%= icon_tag(link.icon_uri) unless link.icon_uri.to_s.blank? %> <%= link.title %>
          <% if link.subtitle.present? %>
            <%= content_tag(:small, link.subtitle, class: 'visible-xs-block visible-sm-inline visible-md-inline visible-lg-inline ms-2') %>
          <% end %>
        <% end %>
      </li>
    <% end %>
  <% end %>
<% end %>

```

OOD Developers / Support, if you get time to review this thread, please let me know if changing to `sort: false` for `_group_items.html.erb` is going to cause me any issues or if there is a better way to do this.

Thanks!

---

<div class="post-metadata">

**Author:** ![bsingleton](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bsingleton/32/3343_2.png) [@bsingleton](https://discourse.openondemand.org/u/bsingleton)\
**Post date:** [November 7, 2025, 4:59pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/9 "2025-11-07T16:59:34Z")

</div>

Thank you so much for digging into this so deeply and I am very glad you have found a possible solution. As far as side effects to this change, I think the reason sort is there in the first place is to organize the `Interactive Apps` dropdown, so modifying that could change the order on those. But if setting `sort: false` fixes the issue, then I think what must be happening is that the `ood_app` object for files is being set without `role: 'files'` which is why that call to `app.links` is not being overridden by the snippet I provided earlier. I try to dig into this more, and make sure that I am not missing something else that overrides that default sort behavior, but in the meantime could you confirm that your `./ood/apps/sys/files/manifest.yml` looks like

> <https://github.com/OSC/ondemand/blob/9bdcf6c06ff11b819b1845e7428dcda81d3cc28c/apps/files/manifest.yml#L1-L9>

In conclusion, I wouldn’t worry too much about your partial substitution as a quick fix, it could mess up order somewhere else but nothing critical. The time that such a fix could cause issues is when you update, as you would have to update your partial with any changes made for 4.1. It seems like a good stopgap though until we find the root cause.

Thanks again for your investigations!

---

<div class="post-metadata">

**Author:** ![bviviano](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/bviviano/32/1514_2.png) [@bviviano](https://discourse.openondemand.org/u/bviviano)\
**Post date:** [November 12, 2025, 6:59pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/10 "2025-11-12T18:59:56Z")

</div>

> [@bsingleton](#):
>
> could you confirm that your `./ood/apps/sys/files/manifest.yml` looks like

```auto
[root@atmos6 ~]# rpm -qf /var/www/ood/apps/sys/files/manifest.yml
ondemand-4.0.7-1.el8.x86_64
[root@atmos6 ~]# 

[root@atmos6 ~]# cat /var/www/ood/apps/sys/files/manifest.yml
---
name: Files App
description: |-
  The Open OnDemand Files App
category: Files
icon: fa://folder
role: files
url: files
new_window: false
[root@atmos6 ~]# 

[root@atmos6 ~]# rpm -V ondemand | grep manifest.yml
[root@atmos6 ~]# 

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/osc/original/2X/b/bae70bd0ed39a3ae769c2108155f4cb3e9da8385.png) [@system](https://discourse.openondemand.org/u/system)\
**Post date:** [May 11, 2026, 7:00pm UTC](https://discourse.openondemand.org/t/sort-order-with-files-drop-down/4592/11 "2026-05-11T19:00:16Z")

</div>

Closed on May 11, 2026, 7:00pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
