title: C# moving an item up/down
body: <p>I got a list that contains items. They all got a 'Sort' column. The sort column is of type int, and it's unique.</p>
  
  <p>Scenario:</p>
  
  <blockquote>
    <p>sort 1; sort 2; sort 3;</p>
  </blockquote>
  
  <p>If the user moves an item up (for example sort 3) in the list (for example to position 1, which would give the sort value 1), the items that are under the one that just got moved up, have to be shifted down in the list, and the sort number should be applied accordingly. In this case all shifted items sort - 1.</p>
  
  <p>So the end state of the scenario looks like this:</p>
  
  <blockquote>
    <p>sort 1 was sort 3; sort 3 was sort 2; sort 3 is now sort 1;</p>
  </blockquote>
  
  <p>How can i do this with <code>LINQ</code>?
  It's not just 3 items. It can be a lot more.</p>
  
  <p>[Edit]</p>
  
  <pre><code> public ActionResult Up(int id)
   {
      var item = dataContext.item.FirstOrDefault(x =&gt; x.item == id);
  
      return View(dataContext.items);
   }
  </code></pre>