g | x | w | all
Bytes Lang Time Link
076Scala 3240830T082540Z138 Aspe
062JavaScript Node.js240828T022656Zl4m2
136Python 3160713T030413Zrebellia
009Uiua240827T200129Znyxbird
006Japt x240827T181535ZShaggy
044Ruby240827T152526ZJordan
014J160714T162827Zmiles
059Haskell160714T132849ZZeta
124C++160713T085839ZKarl Nap
029RETURN160313T025954ZMama Fun
030Perl 6160312T063227ZHotkeys
069Javascript ES6160312T203037ZMama Fun
017Mathematica160312T033909ZCalculat
025Julia160312T064746ZAlex A.
006Seriously160312T063834Zuser4594
011CJam160312T151202ZA Simmon
006MATL160312T092841ZAdnan
015APL160312T065531ZAlex A.
008Pyth160312T035851ZMaltysen
006Jelly160312T050452ZDennis

Scala 3, 76 bytes

(x,y)=>x.sorted(Ordering[Int].reverse).zip(y.sorted).map{case(a,b)=>a*b}.sum

Attempt This Online!

JavaScript (Node.js), 62 bytes

a=>a.map(x=>x.sort((x,y)=>x-y))[i=0].map(x=>i+=a[1].pop()*x)|i

Try it online!

Based on Mama Fun Roll's

-4B by Shaggy by switching Input format

Python 3, 136 bytes

def mdp(n, a, b):
    a = list(reversed(sorted(a)))
    b = sorted(b)
    res = sum([a[i] * b[i] for i in range(len(a))])
    return res

Try it online!

Uiua, 9 bytes

/+×⇌∩⊏∩⊸⍏

Try it!

/+×⇌∩⊏∩⊸⍏
     ⊏ ⊸⍏ # sort
    ∩ ∩   # both
   ⇌      # reverse one
  ×       # multiply
/+        # sum

Japt -x, 6 bytes

Íí*VÍÔ

Try it

Ruby, 44 bytes

->a,b{a.sort.reverse.zip(b.sort).sum{_1*_2}}

Attempt This Online!

J, 14 bytes

+/@(*|.)&(/:~)

Uses the same principle as the others.

Explanation

+/@(*|.)&(/:~)  Input: x on LHS and y on RHS
        &(/:~)  Sort both x and y
     |.         Reverse the sorted y
    *           Multiply the sorted x and reversed sorted y elementwise
+/@             Reduce the products using addition and return

Haskell, 59 bytes

import Data.List
v?u=sum$zipWith(*)(sort v)$reverse$sort u

C++, 124 bytes

#include<algorithm>
int m(int*a,int*b,int n){std::sort(a,a+n);std::sort(b,b+n);int r=0;while(--n>=0)r+=a[n]**b++;return r;}

ungolfed:

#include<algorithm>
int m(int*a,int*b,int n){
 std::sort(a,a+n);
 std::sort(b,b+n);
 int r=0;
 while(--n>=0)
  r+=a[n]*(*b++);
return r;
}

At first i used std::greater<int>() for the sort in b but just reversing the order in the summation is easier.

RETURN, 29 bytes

[{␆␃}\{␆}␄␅[¤¥][×␌]#}␁[¤][+]#]

Try it here.

Replace any ␆␃␄␇ with their unprintable counterparts.

Anonymous lambda that leaves result on stack2. Usage:

""{1 3 0 5-}""{0 2- 4 1}[{␆␃}\{␆}␄␅[¤¥][×␌]#}␁[¤][+]#]!

Explanation

[                                 ]  lambda
 {␆␃}                              sort and reverse first stack
       \{␆}                         sort second stack
            ␄␅                     transpose and flatten
               [  ][  ]#             while loop
                ¤¥                     check if 2 items exist in stack
                    ×                  if so, multiply top 2 items
                     ␌                 and push to stack2
                        }␁          switch to stack2
                           [¤][+]#   sum stack2

Perl 6, 33 30 bytes

{sum @^a.sort Z*@^b.sort.reverse}

Javascript ES6, 69 bytes

a=>b=>a.sort((x,y)=>x-y).map((x,y)=>i+=b.sort((x,y)=>y-x)[y]*x,i=0)|i

Wow, this is way too long.

Mathematica, 30 17 bytes

-13 bytes by murphy

Sort@#.-Sort@-#2&

Function, input is vector1(list),vector2(list) Several revisions:

Plus@@(Sort@#*Reverse@Sort@#2)&(*me*)
Total[Sort@#*Reverse@Sort@#2]& 
Sort@#.Reverse@Sort@#2&        (*alephalpha*)
Sort@#.Sort[#2,#>#2&]&         (*murphy*)
Sort@#.SortBy[#2,-#&]          (*me*)
Sort@#.-Sort@-#2&              (*murphy*)

Julia, 32 25 bytes

x->y->-sort(-x)⋅sort(y)

This is an anonymous function that accepts two arrays and returns an integer. To call it, assign it to a variable and do f(x)(y).

For inputs x and y, we simply compute the dot product of x sorted in reverse order with y sorted. We get x in reverse sorted order by negating all values, sorting, then negating again.

Saved 7 bytes thanks to Dennis!

Seriously, 6 bytes

,SR,S*

Try it online!

Explanation:

,SR,S*
,SR     input first vector, sort, reverse
   ,S   input second vector, sort
     *  dot product

CJam, 11 Bytes

q~$\$W%.*:+

Try it online!

MATL, 6 bytes

Code:

SiSP*s

My first MATL answer :)

Explanation:

S       # Sort the first array
 iS     # Take the second array and sort it
   P    # Flip the array
    *   # Multiply both arrays with each other
     s  # Sum of the result

Try it online!

APL, 15 bytes

{+/⍺[⍒⍺]×⍵[⍋⍵]}

This is a dyadic function that accepts arrays on the left and right and returns an integer. It uses the same approach as my Julia answer: dot product of the sorted arrays, one descending and one ascending.

Try it here

Pyth - 14 8 bytes

I think I figured out the trick.

s*VSQ_SE

Try it online here.

Jelly, 6 bytes

ṢṚ×Ṣ}S

Try it online!

Using brute force is equally short:

Œ!×S€Ṃ

How it works

ṢṚ×Ṣ}S  Main link. Arguments: u (vector), v (vector)

Ṣ       Sort the components of u.
 Ṛ      Reverse.
   Ṣ}   Sort the components of v.
  ×     Multiply the results, element by element.
     S  Compute the sum of the products.