bugGNU Octave - Bugs: bug #42523, sortrows/sort: only cell arrays of...

 
 

bug #42523: sortrows/sort: only cell arrays of character strings may be sorted error

Submitter:  None
Submitted:  Sun 08 Jun 2014 01:41:31 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Rick T Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 19 Dec 2018 06:26:05 AM UTC, comment #5: 

I applied Guillaume's patch and added a BIST test for this bug report.  See https://hg.savannah.gnu.org/hgweb/octave/rev/01f1e70c80b6.  This will be a part of the Octave 5.0 release in January.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Fri 31 Mar 2017 02:21:55 PM UTC, comment #4: 

Attached is a small patch allowing the input to be a cell array.

(file #40222)

Guillaume <gyom>
Thu 15 Dec 2016 04:29:51 PM UTC, comment #3: 

This issue is still present in Octave 4.2.0.

The code line from comment #1 still throws an error.

Hartmut <hardy>
Sun 31 May 2015 05:42:26 PM UTC, comment #2: 

Confirmed still present on the default branch. This error comes from the octave_cell class, where the sort methods are only implemented for cell arrays consisting entirely of strings.

Mike Miller <mtmiller>
Group Member
Sun 08 Jun 2014 05:42:41 PM UTC, comment #1: 

The root cause looks to be with the built-in function, sort().


sort ({3,2,1})
error: sort: only cell arrays of character strings may be sorted


Ben Abbott <bpabbott>
Group Member
Sun 08 Jun 2014 01:41:31 PM UTC, original submission:  

Sortrows seems to be working differently in matlab then in octave.

http://stackoverflow.com/questions/24099275/what-type-of-array-should-i-use-to-combine-numerical-values-and-string-values-an/24099387?noredirect=1#comment37183633_24099387

Here's the code that should work but it seems to come back with an error

"error: sortrows: only cell arrays of character strings may be sorted
error: called from:
error:   /usr/share/octave/3.8.1/m/general/sortrows.m at line 62, column 7"


Here's an example

>> myCell = {1, 2, 'filename1';

             3, 4, 'filename2';
             5, 6, 'filename3'};

>> array = flipud(sortrows(myCell, 1)) %// "1" => col. "flipud" => descending

ans =
    [5]    [6]    'filename3'
    [3]    [4]    'filename2'
    [1]    [2]    'filename1'

>> array(1,1)

ans =
    [5]

>> array(3,3)

ans =
    'filename1'

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #40222:  sr.diff added by gyom (975B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Updated the item)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-20 mtmiller Carbon-CopyRemoved 80942 -
    2018-12-19 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2017-03-31 gyom Attached File- Added sr.diff, #40222
    2015-05-31 mtmiller Release3.8.1 dev
    2014-06-08 bpabbott CategoryOctave Function Libraries
        StatusNone Confirmed
        Operating SystemGNU/Linux Any
        Summarysortrows: only cell arrays of character strings may be sorted error sortrows/sort: only cell arrays of character strings may be sorted error

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code