pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

Sorting bag occurrences by number instead of alphabetically in inspector #17419

Open Ducasse opened 1 day ago

Ducasse commented 1 day ago
inspectionItems: aBuilder
    <inspectorPresentationOrder: 0 title: 'Items'> 

    ^ aBuilder newTable     
        addColumn: (SpStringTableColumn new 
            title: 'Items';
            evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: each key ];
            beNotExpandable;
            beSortable;
            yourself);
        addColumn: (SpStringTableColumn new  
            title: 'Occurences'; 
            evaluated: [ :each | StObjectPrinter asTruncatedTextFrom: (self occurrencesOf: each key) ];
            beSortable;
            compareFunction: [ :c1 :c2 | c1 value < c2 value ];
            yourself);
        items: contents associations;
        yourself