Find Min and Max Values from Array of Tuples in Scala

Hi

Am a newbie in Scala , Am trying to Find the Max and Min value From the Array of Tuples . Could you guys please help me to solve the problem ?

val sc = new SparkContext(new SparkConf().setAppName(“Movie Datset Analysis”).setMaster(“local”))
val moviewithHeader = sc.textFile(“C:\Documents\Data\Movie\movie_metadata.csv”)
val movie = moviewithHeader.mapPartitionsWithIndex { (idx , iter) => if(idx==0) iter.drop(1) else iter}

val Director = movie.map(x => (x.split(",")(1) , 1 )).reduceByKey( _ + _ , 5)
Director.collect().foreach(println)

Now I having the intermediate results as (DirectorName,Movie Count) below which has the all the Director name and their movie Count :

(Simon Wells,2)
(Fenton Bailey,2)
(Gideon Raff,1)
(Mark Young,1)
(Jeta Amata,1)
(Michael Hoffman Jr.,1)
(Aleksey German,1)
(Monte Hellman,1)
(Jean-Pierre Jeunet,5)
(Allen Coulter,1)
(Paul King,1)
(Tom Tykwer,5)
(Jonathan Mostow,4)
(Ethan Coen,7)
(Lee Toland Krieger,2)
(Nnegest Likké,1)
(Karyn Kusama,2)
(Alejandro Agresti,1)
(Lena Dunham,1)
(Paul Weitz,6)

From here i want to Find the Max and Min value ?

Thanks
Esakki

@esak please check out 3 question Find the following from the given products.csv (for those who are preparing for CCA175)

2 Likes

Thanks @email2dgk it was really helpfully for the examination. It clears my doubt . Thanks again