The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Sort by two attributes

MuehliManMuehliMan Member Posts: 85 Maven
edited November 2018 in Help
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

Answers

  • colocolo Member Posts: 236 Maven
    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
Sign In or Register to comment.