From 1e011256e9715a6112fb17058fcdce3e151b34a4 Mon Sep 17 00:00:00 2001 From: sandoz Date: Tue, 7 Apr 2009 01:54:07 +0800 Subject: [PATCH] Remove all non-digits before sorting by order number in finance/balancing * Since order_number is a string, there can be more than a-zA-Z + digits Signed-off-by: bennibu --- app/controllers/finance/balancing_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/finance/balancing_controller.rb b/app/controllers/finance/balancing_controller.rb index 30d907d3..d2292d9a 100644 --- a/app/controllers/finance/balancing_controller.rb +++ b/app/controllers/finance/balancing_controller.rb @@ -34,9 +34,9 @@ class Finance::BalancingController < ApplicationController ) if params[:sort] == "order_number" - @articles = @articles.sort { |a,b| a.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> b.article.order_number.gsub(/[a-zA-Z]/, "").to_i } + @articles = @articles.sort { |a,b| a.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> b.article.order_number.gsub(/[^[:digit:]]/, "").to_i } elsif params[:sort] == "order_number_reverse" - @articles = @articles.sort { |a,b| b.article.order_number.gsub(/[a-zA-Z]/, "").to_i <=> a.article.order_number.gsub(/[a-zA-Z]/, "").to_i } + @articles = @articles.sort { |a,b| b.article.order_number.gsub(/[^[:digit:]]/, "").to_i <=> a.article.order_number.gsub(/[^[:digit:]]/, "").to_i } end view = params[:view]