Outliner: Alphabetical sorting sorts shorter names last. #72878

Closed
opened 2020-01-03 15:45:19 +01:00 by Stanislav Blinov · 7 comments

Blender Version
Broken: 2.81, 2.82
Worked: 2.80 and before

Short description of error
Names such as "Cube, Cube.001, Cube.002" are ordered as "Cube.001, Cube.002, Cube", whereas you'd normally expect shorter name ordered first if it otherwise matches, and that is the way 2.80 and before do this. I'm aware there were some changes to how numeric parts are considered, but was the length ordering change intentional?

Comparison between 2.80 and 2.81 (2.82):
image.png

Exact steps for others to reproduce the error

In the default file, duplicate the Cube twice and note the order of objects in the Outliner. "Cube" will come after "Cube.001" and "Cube.002". Note that this is, of course, with alphabetical sorting enabled.

**Blender Version** Broken: 2.81, 2.82 Worked: 2.80 and before **Short description of error** Names such as "Cube, Cube.001, Cube.002" are ordered as "Cube.001, Cube.002, Cube", whereas you'd normally expect shorter name ordered first if it otherwise matches, and that is the way 2.80 and before do this. I'm aware there were some changes to how **numeric** parts are considered, but was the length ordering change intentional? Comparison between 2.80 and 2.81 (2.82): ![image.png](https://archive.blender.org/developer/F8258419/image.png) **Exact steps for others to reproduce the error** In the default file, duplicate the Cube twice and note the order of objects in the Outliner. "Cube" will come after "Cube.001" and "Cube.002". Note that this is, of course, with alphabetical sorting enabled.

Added subscriber: @Stan_Pancakes

Added subscriber: @Stan_Pancakes

Added subscriber: @rocketman

Added subscriber: @rocketman

I can confirm, although this issue seems to be caused specifically by how the period character is ordered, not by string length. For instance, if you remove the period or replace it with white space, the order works again as one might expect.

I can confirm, although this issue seems to be caused specifically by how the period character is ordered, not by string length. For instance, if you remove the period or replace it with white space, the order works again as one might expect.
Member

Added subscriber: @Harley

Added subscriber: @Harley
Member

D:\blender-2.8-git\blender\source\blender\blenlib\intern\string.c BLI_strcasecmp_natural() is definitely made to do that.

The strings are the same until it gets past "Cube". At that point the one with the period wins over the other no matter that it ended. This is because it (from comment) first check for '.' so "foo.bar" comes before "foo 1.bar

My gut feeling is that we just need to check for zero in there too, so changing line 702-704 from:

    if (c1 == '.' && c2 != '.') {
      return -1;
    }

To:

    if (c1 == '.' && c2 != '.' && c2 != 0) {
      return -1;
    }

And then the shorter will win regardless. But my gut feeling might be wrong. I've tried to muck about in there before and was not considering some important details.

D:\blender-2.8-git\blender\source\blender\blenlib\intern\string.c BLI_strcasecmp_natural() is definitely made to do that. The strings are the same until it gets past "Cube". At that point the one with the period wins over the other no matter that it ended. This is because it (from comment) *first check for '.' so "foo.bar" comes before "foo 1.bar* My gut feeling is that we just need to check for zero in there too, so changing line 702-704 from: ``` if (c1 == '.' && c2 != '.') { return -1; } ``` To: ``` if (c1 == '.' && c2 != '.' && c2 != 0) { return -1; } ``` And then the shorter will win regardless. But my gut feeling might be wrong. I've tried to muck about in there before and was not considering some important details.

This issue was referenced by f52d9a878d

This issue was referenced by f52d9a878de95ca50788f1773d2c7c48301a6789
Member

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Julian Eisel self-assigned this 2020-01-08 16:10:46 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#72878
No description provided.