title: Filtering JSON according to some rules
body: <p>I'm stuck conceptually on this problem. I have some data:</p>
  
  <pre><code>const measurements = [
    {
      value: 162000,
      properties: [
        {
          name: "Selection Status",
          value: "Most recent value chosen",
        },
        {
          name: "Measurement Method",
          value: "Method of Disks, Single Plane",
        },
        {
          name: "Image Mode",
          value: "2D mode",
        },
        {
          name: "Image View",
          value: "Apical two chamber",
        },
      ],
    },
    {
      value: 171000,
      properties: [
        {
          name: "Selection Status",
          value: "Most recent value chosen",
        },
        {
          name: "Measurement Method",
          value: "Method of Disks, Single Plane",
        },
        {
          name: "Image Mode",
          value: "2D mode",
        },
        {
          name: "Image View",
          value: "Apical four chamber",
        },
      ],
    },
    {
      value: 173000,
      properties: [
        {
          name: "Measurement Method",
          value: "Method of Disks, Biplane",
        },
        {
          name: "Image Mode",
          value: "2D mode",
        },
      ],
    },
    {
      value: 157000,
      properties: [
        {
          name: "Measurement Method",
          value: "Cube Method",
        },
        {
          name: "Image Mode",
          value: "2D mode",
        },
      ],
    },
    {
      value: 141000,
      properties: [
        {
          name: "Measurement Method",
          value: "Teichholz",
        },
        {
          name: "Image Mode",
          value: "2D mode",
        },
      ],
    },
  ];
  </code></pre>
  
  <p>My goal is to choose the measurement according to some greedy rules. They might look a little like this:</p>
  
  <pre><code>function findMeasurement(
    measurements: Measurement[],
    filter: MeasurementFilter,
  ): Measurement | undefined {
    return undefined
  }
  </code></pre>
  
  <p>where a MeasurementFilter might look a little like this:</p>
  
  <pre><code>const MATCH_ANYTHING = /.+/;
  
  {
    'Image Mode': [/2D mode/, MATCH_ANYTHING],
    'Image View': [/Apical four chamber/, /Apical two chamber/, MATCH_ANYTHING],
    'Measurement Method': [
      /Method of Disks, Biplane/,
      /Method of Disks, Single Plane/,
      /Teichholz/,
      MATCH_ANYTHING,
    ],
    'Selection Status': [/Mean value chosen/, MATCH_ANYTHING],
  }
  </code></pre>
  
  <p>This filter should look for measurements that match from most specific to least specific. So I want to iterate through the data array, and find the measurement that matches most closely. So it would be measurement 2 with value 171000, as it has <code>Apical four chamber</code>, <code>2D mode</code>. I want to match top to bottom in my filter.</p>
  
  <p>Does this make sense? Are there any flaws I am missing? Can anyone get me started on a function implementation/pseudo code?</p>