title: Ampscript: desc sort field values from data extension and pass them to another variable
body: <p><strong>I have a data extensions with 6 fields:</strong></p>
  
  <pre><code>EmailAdress (type: EmailAdress, unique)
  Field1 (type: number, not nullable)
  Field2 (type: number, not nullable)
  Field3 (type: number, not nullable)
  Field4 (type: number, not nullable)
  Field5 (type: number, not nullable)
  </code></pre>
  
  <p><strong>I have 3 objectives:<br><br></strong>
  <em>1. Pass the values of each field into ampscript variables (the easy part)<br></em></p>
  
  <pre><code>%%[
  Set @var1 = Field1
  Set @var2 = Field2
  Set @var3 = Field3
  Set @var4 = Field4
  Set @var5 = Field5
  ]%%
  </code></pre>
  
  <p><em>2. Sort the variables descending based on their values and (3) pass them on to one of the five contentareas.</em></p>
  
  <pre><code>%%=ContentAreaByName("my contents\Campaigns\mainitem\@maxvar1")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem1\@maxvar2")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem2\@maxvar3")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem3\@maxvar4")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem4\@maxvar5")=%%
  </code></pre>
  
  <p><strong>If, for example the values of my fields are:</strong></p>
  
  <pre><code>Field1: 10
  Field2: 15
  Field3: 5
  Field4: 1
  Field5: 100
  </code></pre>
  
  <p><strong>Then my five contentareas should be populated as following:</strong></p>
  
  <pre><code>%%=ContentAreaByName("my contents\Campaigns\mainitem\@field5")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem1\@field2")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem2\@field1")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem3\@field3")=%%
  %%=ContentAreaByName("my contents\Campaigns\subitem4\@field4")=%%
  </code></pre>
  
  <p>Passing the values to amscript values is very easy. But desc sorting them and passing them on the appropiate @maxvar seems to be a bit of a stretch for my limited ampscript knowledge. </p>
  
  <p>Any help is greatly appreciated!</p>