Skip to content
4 changes: 3 additions & 1 deletion app/controllers/product_drives_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def index
@paginated_product_drives = @product_drives.page(params[:page])

# to be used in the name filter to sort product drives in alpha order
@product_drives_alphabetical = @product_drives.sort_by { |pd| pd.name.downcase }
@product_drives_alphabetical = @product_drives.to_a.sort_by do |pd|
pd.name.downcase.split(/(\d+)/).map { |chunk| chunk.match?(/^\d+$/) ? chunk.to_i : chunk }
end
@item_categories = current_organization.item_categories
@selected_name_filter = filter_params[:by_name]
@selected_item_category = filter_params[:by_item_category_id]
Expand Down
Loading