in reply to Sorting an array of strings when some of the strings have commas in them?

Without a sample file with starting headers, column headers and data lines, I'm just making a guess, but I think you will get your data sorted if you add a line.
tr/,.//d for $company_name_a, $company_name_b; fc($company_name_a) cmp fc($company_name_b) or $invoice_ID_a <=> $invoice_ID_b
This transliteration would delete commas and periods from the company name before the sort comparisons.

Hope this helps.

  • Comment on Re: Sorting an array of strings when some of the strings have commas in them?
  • Download Code

Replies are listed 'Best First'.
Re^2: Sorting an array of strings when some of the strings have commas in them?
by perldigious (Priest) on Dec 11, 2015 at 22:41 UTC

    Thanks for the reply. It had occurred to me to remove the commas prior to doing the sort, or rather to make local copies of them to remove commas from and then sort by those modified local copies without changing the original data. I guess I was just hoping for an explanation to why it sorts the way it does for me as is, and for a fix that was more straightforward.