🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Sort by two attributes

MuehliManUser: "MuehliMan"
New Altair Community Member
Updated by Jocelyn
Dear RM community,

I would like to sort my dataset according to TWO attributes:

First the set needs to be sortied acc. to the generation (number) and then it needs to be sorted according to accuracy, to. How do I manage to do this in RM?

Cheers,
Markus

Find more posts tagged with

Sort by:
1 - 1 of 11
    coloUser: "colo"
    New Altair Community Member
    Hi Markus,

    chaining two "Sort" operators works for me. You have to sort the least important attributes first. In your case you first have to sort by accuracy and then sort by number to achieve the desired sorting order.

    A little example to illustrate:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.008">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process">
        <process expanded="true" height="607" width="747">
          <operator activated="true" class="generate_data" compatibility="5.1.008" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
            <parameter key="number_of_attributes" value="2"/>
            <parameter key="attributes_lower_bound" value="0.0"/>
            <parameter key="datamanagement" value="int_array"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="5.1.008" expanded="true" height="76" name="Select Attributes" width="90" x="179" y="30">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="label"/>
            <parameter key="invert_selection" value="true"/>
            <parameter key="include_special_attributes" value="true"/>
          </operator>
          <operator activated="true" class="sort" compatibility="5.1.008" expanded="true" height="76" name="Sort" width="90" x="313" y="30">
            <parameter key="attribute_name" value="att2"/>
          </operator>
          <operator activated="true" class="sort" compatibility="5.1.008" expanded="true" height="76" name="Sort (2)" width="90" x="447" y="30">
            <parameter key="attribute_name" value="att1"/>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Select Attributes" from_port="example set output" to_op="Sort" to_port="example set input"/>
          <connect from_op="Sort" from_port="example set output" to_op="Sort (2)" to_port="example set input"/>
          <connect from_op="Sort (2)" from_port="example set output" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    Regards
    Matthias