[Question]
  [
You're a chef and you love cooking with your spices, but recently you've taken a liking to organizing your spices based on how often you use them. But you have no time to be writing down when you used your spice last. Simply, you swap and move spices around, and this seems to do the trick.
But of course you're a chef and that means you have some cooks with you. You 
decide to tell them the simple rules of engagement with your spices.
1. If you recently used a spice, move it up one in the spice rack
2. If you didn't use any spices at all, e.g. `[]` empty movement list,
then the spice list is not affected.
3. You may put any spice into my spice holder, but if you use it, make
sure to move it.
4. The list can contain anything. But because these are spices we are
working with. It is preferred that you use names of spices.
5. Spices should be unique. Too many of the same spices spoil the
broth... or however that saying goes
Normal code-golf rules apply.
### Example of Oregano being used again and again.
```
pepper  pepper  pepper  pepper  oregano
paprika paprika paprika oregano pepper
salt    salt    oregano paprika paprika
cumin   oregano salt    salt    salt
oregano cumin   cumin   cumin   cumin
```
## Task
Input a list of spices, and a list of what spices got used, then output the final list.
## Example
Input
```
[pepper, paprika, salt, cumin, oregano], [oregano, cumin, cumin, salt, salt, salt]
```
Output
```
[salt, pepper, paprika, cumin, oregano]
```
How this looks
```
pepper  pepper  pepper  pepper  pepper  pepper  salt
paprika paprika paprika paprika paprika salt    pepper
salt    salt    salt    cumin   salt    paprika paprika
cumin   oregano cumin   salt    cumin   cumin   cumin
oregano cumin   oregano oregano oregano oregano oregano
```
Input 
```
[pepper, paprika, salt, cumin, oregano], [salt, salt, salt, salt, salt, salt, salt, salt, salt, salt, salt, salt, oregano]
```
Output
```
[salt, pepper, paprika, oregano, cumin]
```
  
[Answer]
# [Haskell](https://www.haskell.org/), 48 bytes
`foldl(?)` is an anonymous function taking two list arguments and returning a list, with all elements of the same (`Eq`-comparable) type.
Use as `foldl(?)["pepper", "paprika", "salt", "cumin", "oregano"]["oregano", "cumin", "cumin", "salt", "salt", "salt"]`.
```
foldl(?)
(x:y:r)?n|y==n=y:x:r|s<-y:r=x:s?n
s?n=s
```
[Try it online!](https://tio.run/##rY7BasMwDIbvfgqT7mBDkgcw80IZo5dRCmOnLAeROq2poxg5oQnrnj1LOho22GlMIP5PQr@kI4STcW58T1b8eb3dvK43T/xxt@Or5IOxGixqi60hKNu7Dp1FE9IavGB8inBszmmHZUc08CoVZGCv1EtLFg/Jg8i/qIhvIOXVJtPrHsYq/TZWjds7kUkmejUokhleBq1RD6pXdAn3ydTUvQoZsil1GEeRR954byiKeeTBkz3BjAFcO2vZ1RZnaMgcAJuoiHm@FN8HFrhZf2gx/fSnU79u@0ddjkn2CQ "Haskell – Try It Online")
* `foldl(?) s m` starts with the (spice rack) list `s` and combines it with each element (spice) from `m` in order, using the operator `?`.
* `s?n` uses the spice `n` from the spice rack `s` and returns the resulting spice rack.
	+ If `s` has at least two elements, `?` checks whether the second one is equal to `n`, and if so switches the first two elements. If not equal, `?` keeps the first element fixed and recurses on the rest.
	+ If `s` has at most one element, `?` returns it unchanged.
[Answer]
# [Chef](http://search.cpan.org/~smueller/Acme-Chef/), ~~875~~ 843 bytes
```
S.
Ingredients.
1 g T
0 g Z
J
I
Method.
Put Z into mixing bowl.Take I from refrigerator.B I.Put I into mixing bowl.Take I from refrigerator.B until bed.Take I from refrigerator.V I.Put Z into 2nd mixing bowl.N T.Fold J into mixing bowl.Put J into mixing bowl.Remove I.Fold T into mixing bowl.Put J into 2nd mixing bowl.N until ned.Fold T into mixing bowl.Put T into mixing bowl.Fold J into 2nd mixing bowl.Put J into mixing bowl.C T.Stir for 1 minute.Put Z into mixing bowl.Fold T into mixing bowl.C until ced.Fold T into 2nd mixing bowl.G T.Put T into mixing bowl.Fold T into 2nd mixing bowl.G until ged.Put I into mixing bowl.Fold T into mixing bowl.Take I from refrigerator.V until ved.Fold T into mixing bowl.L T.Put T into 2nd mixing bowl.Fold T into mixing bowl.L until led.Pour contents of 2nd mixing bowl into baking dish.
Serves 1.
```
-32 bytes thanks to *Jonathan Allan* by removing `the` where I wouldn't think it will work.
Chef has no string types, so the ingredients are positive integers. 0 is used to separate the starting list from used ingredients and to end the used ingredients list. See the TIO link for an example.
**Pseudocode explaination:**
```
A, B: stack
T, J, IN: int
T = 1
A.push(0) // used as the marker for the bottom of the stack
IN = input() // input the first list
while(IN):
    A.push(IN)
    IN = input()
IN = input() // for each used ingredient
while(IN):
    B.push(0)
    while(T): // move all ingredients up to and including the one we are moving right now to the second stack
        T = A.peek() - IN
        B.push(A.pop())
    A.push(B.pop())
    if(A.peekUnderTop() != 0):
        A.swapTopTwoItems()
    T = B.pop() // move the ingredients from the second stack back to the first
    while(T):
        A.push(T)
        T = B.pop()
    T = IN // to make it non-zero for next iteration
    IN = input(0
print(A.inverted())
```
[Try it online!](https://tio.run/##lZPBToQwEIbv8xTzBM2yetCrm2jYrMYI8bA3oAM0C52kFPTtsVgOLktJDElDpnz/fG1pUVM5jokAiHVlSCrSthMQYYUp7Nx4hiPEAK9ka5YC3nuLZ1TaMrbqW@kKc/5qRJpdCGMsDbdoqDSqIpNZNuIJYzEx8b@YXlvVYE4y/NHnHDzL7LW8Cn/DVDxzI/F423jCVsof1PLgmnku3eRu23ll7ZS38JXyX8tlbMD04BaXWGWwZIORm9K9JRE4mpDOYVYuFspLhxfXbEs9iPn4ysUHfoCQ2caZ@8xhY5dP17pLrTDmo5tJl3uDBWs73QXkchni6Ty7TAWputrdnoTMQB1GYhzvYQ938ADRI@zcy/rzO/kD "Chef – Try It Online")
[Answer]
# JavaScript, 61 bytes
```
a=>b=>b.map(v=>(p=a.indexOf(v))&&a.splice(p-1,2,a[p],a[p-1]))
```
Input format:
* f(list\_of\_spices)(list\_of\_what\_spices\_got\_used)
* two list are array of string
Output:
* list\_of\_spices is modified in-place.
```
f=
a=>b=>b.map(v=>(p=a.indexOf(v))&&a.splice(p-1,2,a[p],a[p-1]))
a = ['pepper', 'paprika', 'salt', 'cumin', 'oregano'];
b = ['salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'salt', 'oregano'];
f(a)(b);
document.write(JSON.stringify(a))
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~15~~ 14 bytes
```
Fλṁ↔`C⁰tMo→=¢⁰
```
Inputs are lists of strings (it also works on other kinds of lists).
[Try it online!](https://tio.run/##yygtzv7/3@3c7oc7Gx@1TUlwftS4ocQ3/1HbJNtDi4Ds////RysVpBYUpBYp6SgVJBYUZWYnAlnFiTklQCq5NDczD0jnF6WmJ@blK8UCVUOlqErBzQcA "Husk – Try It Online")
-1 byte thanks to H.PWiz
## Explanation
```
Fλṁ↔`C⁰tMo→=¢⁰  Implicit inputs (two lists).
F               Fold second input using the first as initial value
 λ              with this anonymous function:
                 Arguments x (list of spices) and s (used spice).
                 For example, x=["a","b","c","d"] and s="c".
            ¢⁰   Repeat x infinitely: ["a","b","c","d","a","b","c","d"..
        M        For each item,
           =     test equality to s: [0,0,1,0,0,0,1,0..
         o→      and increment: [1,1,2,1,1,1,2,1..
       t         Drop first element: [1,2,1,1,1,2,1..
    `C⁰          Cut x to these lengths: [["a"],["b","c"],["d"]]
  ṁ↔             Reverse each slice and concatenate: ["a","c","b","d"]
```
I have to repeat `x` infinitely, since otherwise the list would lose its last element when we use the topmost spice.
It would be enough to add a trailing 1, but repetition takes fewer bytes.
A better way would be to rotate the list instead of dropping its first element, but Husk has no built-in for that.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~72~~ ~~71~~ 69 bytes
New answer, in the spirit of my original attempt.
```
r,u=input()
for x in u:i=r.index(x);r.insert(i/~i+i,r.pop(i))
print r
```
[Try it online!](https://tio.run/##VYvBCsIwEETv/Yq9JcFQwaPSLyk9BI26qLvLNoH04q9Hg1j09N4MM7KkK9OuVvV5QJKcrOvOrFAACfIeB@2RTrHY4g5N56jJ4vaJG/TaC4tF5zpRpARa62gkikQ1HoyEd30LTedwT43H/EBqwhovgdhMHsY1/A5W@V7/@cH0Ag "Python 2 – Try It Online")
Other solution:
# [Python 2](https://docs.python.org/2/), 69 bytes
```
r,u=input()
for x in u:i=r.index(x)-1;r[i:i+2]=r[i:i+2][::-1]
print r
```
[Try it online!](https://tio.run/##VYvBCsIwEETv/Yq9pcVWaI@RfEnIIWjURd0sawLx66NBWvT03gwz/ErXSEutMmaDxDn1Q3eOAgWQIGs0skc6hdKXYZoPYlHjbnFmFav1NLuOBSmB1GoVB@YgagTF/lPffNOnv6fGY34gNYkSLp6iciPYLfwONlmv//zCvQE "Python 2 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 80 bytes
```
def g(r,q):
 for s in q:
  i=r.index(s)
  if i:r[i-1],r[i]=r[i],r[i-1]
 return r
```
[Try it online!](https://tio.run/##VYyxDsIwDERn8hXekkoGCcZKZeQn2gyBpiUCnNRNJfj6khRRweK7Z58vvOLV02GeW9tBrxiHohTQeYYRHMGQAFzFO0etfaqxyNiBK7l2273GJLrKAz8LAWzjxAS8FJ6UwXMq3AR2FCEByoaaWB0l9stNiJOqZbAhWJYIMpgUvZlsR3OPWS/Tw1E2nm1vyEuNUK/wG1jN9/VPdTG/AQ "Python 2 – Try It Online")
[Answer]
# Java 8, ~~87~~ ~~86~~ 76 bytes
```
a->b->b.forEach(x->{int i=a.indexOf(x);a.set(i,a.set(i>0?i-1:i,a.get(i)));})
```
Takes two inputs as `ArrayList<String>` and modifies the first List instead of returning a new one to save bytes.
-10 bytes thanks to *@Nevay*.
**Explanation:**
[Try it here.](https://tio.run/##zZDBbsIwDIbvfQqLUyK10XZdodM0badNO3CcdjAhMEObREnKQIhn71JaQBoITTtNiuw4v@X/ixe4wsxYpRfTZUOVNS7AIr6JOlApHpzDzQv5kCeXNX9BmNVaBjJaPBrt60q5az3P/SVPZInewyuShm0C4AMGknDQh0eU4Tg40vMihcP8c60oQMIIGsyKSTxiZtwTyk@2zoot6QA0QkF6qtZvM7bmOQqvAqO0z8XNPWW3d209b2vOeb7jTZ5ELFtPyojV060MTaGKyKwzfv8A5C09wBkTeEtS@Yil1ddJZt0eBfp9NbDKWuVSsGgdLTEFj2VIQdYV6RSMU3PUZiC8LSl2pzBo6faOUqC15YZ1PlyglMoGdtWtn3ec36fO8xR/@PWG440PqhKmDiKy6lDqg3en78N//PXP7/01Xub61XZ2ya75Bg)
```
a->b->{                  // Method with two ArrayList<String> parameters and no return-type
  b.forEach(x->{         //  Loop over the second input-List
    int i=a.indexOf(x);  //   Get the index of the current item in the first input-List
    a.set(i,a.set(       //    Swap items:
      i>0?               //     If the current item is not the top item yet:
       i-1               //      Use the item above it
      :                  //     Else:
       i,                //      Use itself
         a.get(i)));     //     And swap it with the current item
  })                     //  End of loop
                         // End of method (implicit / single-line body)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~20~~ 18 bytes
```
vDyk>Ig‚£`U`2(@)X«
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/zKUy284z/VHDrEOLE0ITjDQcNCMOrf7/P1o9vyg1PTEvX11HQT25NDczD4VRnJhTgkHHckWrF6QWFKQWgYQKEguKMrMTkVXBtcPMjgUA "05AB1E – Try It Online")
**Explanation**
```
v                    # for each used spice
 D                   # duplicate current spice order
  yk                 # get the index of the current spice
    >                # increment
     Ig‚             # pair with the number of unique spices
        £            # split the spice list into pieces of these sizes
         `           # split as 2 separate lists to stack
          U          # store the list of spices below the current one in X
           `         # push the current spice and all above separately to stack
            2(@      # swap the second item to the top of the stack
               )     # wrap in a list
                X«   # append the rest of the spices
```
[Answer]
## C#, 125 117 81 79 bytes
```
(c,n)=>{foreach(var i in n){var j=c.IndexOf(i);if(j!=0){c[j]=c[--j];c[j]=i;}}};
```
[Try it on .NET Fiddle](https://dotnetfiddle.net/2ZATyE)
golfed off 36 bytes thanks to [raznagul](https://codegolf.stackexchange.com/users/42502/raznagul)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 16 bytes
```
vÐyk©DĀ-DUè®ǝyXǝ
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/7PCEyuxDK12ONOi6hB5ecWjd8bmVEcfn/v8frVScmFOipKNAMzq/KDU9MS9fKZYrWqkgtaAgtQgkWpBYUJSZnYisMLk0NzMPRQcA "05AB1E – Try It Online")
[Answer]
# Mathematica, 52 bytes
but it is my first post here so please be kind if counted incorrectly :)
```
Keys@Sort@Merge[{PositionIndex@#,-Counts@#2},Total]&
```
And an example:
```
Keys@Sort@Merge[{PositionIndex@#, -Counts@#2}, Total] &[
    {pepper, paprika, salt, cumin, oregano}
  , {oregano, cumin, cumin, salt, salt, salt}
]
```
> 
> {salt, pepper, paprika, cumin, oregano}
> 
> 
> 
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 18 bytes
```
l~{a\_@#__g-e\}%~`
```
[Try it online!](https://tio.run/##S85KzP3/P6euOjEm3kE5Pj5dNzWmVrUu4f//aKWC1IKC1CIlBaWCxIKizOxEIKs4MacESCWX5mbmAen8otT0xLx8pViFaJgUVSm4@QA "CJam – Try It Online")
]