Sort pages in sitemap by frontmatter data

Hi everyone,

I would like to sort the pages in the sitemap by the data given in the frontmatter of the pages. I tried to use

pages = Array.new
sitemap.resources.each do |page|
   pages.push page if page.url =~ /\.html/
end
pages.sort_by do |a, b|
   a.nil? or a.data.nil? or a.data.dev.nil? ? -1 : b.nil? or b.data.nil? or b.data.dev.nil? ? 1 : a.data.dev <=> b.data.dev
end

But that doesn’t work for me. Do you guys have any idea how to achieve this?

Looks like you’re not using the result of pages.sort_by, it doesn’t operate in-place.