Index: src/FunctionApproximation/Extractors.cpp
===================================================================
--- src/FunctionApproximation/Extractors.cpp	(revision caa00e9205bd9a094ecd605ffbf2f9685af58b83)
+++ src/FunctionApproximation/Extractors.cpp	(revision df350cb1331cc18177269e53b2fb8b9d48232cf4)
@@ -506,2 +506,61 @@
 }
 
+FunctionModel::arguments_t Extractors::reorderArgumentsByParticleTypes(
+    const FunctionModel::arguments_t &args,
+    const ParticleTypes_t &_types
+    )
+{
+  typedef std::list< argument_t > ListArguments_t;
+  ListArguments_t availableList(args.begin(), args.end());
+  FunctionModel::arguments_t returnargs;
+  returnargs.reserve(args.size());
+
+  // TODO: fill a lookup map such that we don't have O(M^3) scaling, if M is number
+  // of types (and we always must have M(M-1)/2 args) but O(M^2 log(M)). However, as
+  // M is very small (<=3), this is not necessary fruitful now.
+//  typedef ParticleTypes_t firsttype;
+//  typedef ParticleTypes_t secondtype;
+//  typedef std::map< firsttype, std::map< secondtype, boost::ref(args) > > ArgsLookup_t;
+//  ArgsLookup_t ArgsLookup;
+
+  // basically, we have two choose any two pairs out of types but only those
+  // where the first is less than the letter. Hence, we start the second
+  // iterator at the current position of the first one and skip the equal case.
+  for (ParticleTypes_t::const_iterator firstiter = _types.begin();
+      firstiter != _types.end();
+      ++firstiter) {
+    for (ParticleTypes_t::const_iterator seconditer = firstiter;
+        seconditer != _types.end();
+        ++seconditer) {
+      if (seconditer == firstiter)
+        continue;
+
+      // search the right one in _args (we might allow switching places of
+      // firstiter and seconditer, as distance is symmetric).
+      ListArguments_t::iterator iter = availableList.begin();
+      for (;iter != availableList.end(); ++iter) {
+        LOG(3, "DEBUG: Current args is " << *iter << ".");
+        if ((iter->types.first == *firstiter)
+              && (iter->types.second == *seconditer)) {
+          returnargs.push_back( *iter );
+          break;
+        }
+        else if ((iter->types.first == *seconditer)
+              && (iter->types.second == *firstiter)) {
+          argument_t flippedtypes(*iter);
+          std::swap( flippedtypes.indices.first, flippedtypes.indices.second );
+          std::swap( flippedtypes.types.first, flippedtypes.types.second );
+          returnargs.push_back( flippedtypes );
+          break;
+        }
+      }
+      ASSERT( iter != availableList.end(),
+          "Extractors::reorderArgumentsByParticleTypes() - could not find arguments to "
+          +toString(*firstiter)+","+toString(*seconditer)+".");
+      availableList.erase(iter);
+    }
+  }
+//  LOG(2, "DEBUG: Final list of args is " << returnargs << ".");
+
+  return returnargs;
+}
Index: src/FunctionApproximation/Extractors.hpp
===================================================================
--- src/FunctionApproximation/Extractors.hpp	(revision caa00e9205bd9a094ecd605ffbf2f9685af58b83)
+++ src/FunctionApproximation/Extractors.hpp	(revision df350cb1331cc18177269e53b2fb8b9d48232cf4)
@@ -33,4 +33,8 @@
   typedef std::map< element_t, chargeiters_t > elementtargets_t;
   typedef std::vector< chargeiters_t > targets_per_combination_t;
+  //!> typedef for particle designation
+  typedef int ParticleType_t;
+  //!> typedef for a vector of particle designations
+  typedef std::vector<ParticleType_t> ParticleTypes_t;
 
   /** Namespace for some internal helper functions.
@@ -297,4 +301,17 @@
       );
 
+  /** Reorder arguments according to types.
+   *
+   * If particle types is (0,1,2) and three argumens, each with a pair of types,
+   * are given, then the alignment will be: (0,1), (0,2), and (1,2).
+   *
+   * \param args arguments to reorder
+   * \param _types particle type vector
+   * \return reordered args
+   */
+  FunctionModel::arguments_t reorderArgumentsByParticleTypes(
+      const FunctionModel::arguments_t &args,
+      const ParticleTypes_t &_types
+      );
 }; /* namespace Extractors */
 
