Aggregating lists in Google Sheets based on weights - sorting

I'm trying to figure out how generate an ordered list based on the weights of items in several other lists.
Here's the criteria
The number of items in the lists likely won't change (say 20 per list)
The items in the list may change (a lot). new items might appear
The higher in a list the more weight given
The items with the most weight are at the top of the final list
Example
name (weight)
List 1
Bob (100)
Fred (95)
Mary (90)
James (85)
List 2
Mary (100)
Fred (95)
Kate (90)
James (85)
Alan (80)
Final list would automatically come out as
Fred (195)
Mary (190)
James (160)
Bob (100)
Kate (90)
Alan (80)
I'm not looking for an answer as I realise I haven't even given my own thoughts. I've tried various sorting functions in google Sheets but I think I'm just way off. Can someone point me to a resource or a function/script to investigate, please?

try:
=ARRAYFORMULA(FLATTEN(QUERY(TRANSPOSE(TEXT(QUERY(SPLIT({A2:A5; A8:A12}, " ()"),
"select Col1,sum(Col2) group by Col1 order by sum(Col2) desc label sum(Col2)''"),
{"#", "\(#\)"})),,9^9)))

Related

Find a value in a column from an array

Hoping someone can help, not even sure how to phrase the question! We have started something of a Harry Potter challenge system at our school. We've divided the pupils into houses and will be awarding points just like in the books. I have managed to dynamically rank the pupils when points are awarded but I need a dynamic overall tally/ranking for each house. So I need a formula that will search the pupil list, find out which house they're in and then add their points to each house total.
I'm something of an enthusiastic amateur when it comes to Excel but this has stumped me.
If you put them into a table with their name, house, and points, you could have a "house rank" by this formula:
=SUM( ($B$2:$B$27=B2)*($C$2:$C$27>C2) ) + 1
putting the formula in this example in E2 (enter it with CTRL+SHIFT+ENTER if you have an older version of Excel) and then copying it down for each pupil.

Gale Shapley matching algorithm with fairness

(sorry for the poor english)
Hi, I'm trying to implement Gale, Shapley algorithm to different sized groups. I found a trick that consisted to duplicate "offers" for a given man (ie: a man's preferences is repeated in the men's preference list) and this second offer is added in women's lists.
example:
Let men be {1,2} and women {3,4}, I want some of the men to have more than one marriage (let 1 be this lucky/unlucky guy)
From the start the preferences lists of men is:
1:[3,4]
2:[4,3]
the preferences lists of women is:
3:[2,1]
4:[1,2]
It is a one-to-one matching problem.
To handle the case of polygamy, I follow the trick.
I can create a man 1' which hold the second offer of man 1 and has the same preference as 1
1':[3,4]
and I update women's list to add 1':
3:[2,1,1']
4:[1,1',2]
It becomes a many-to-one matching problem.
However it's now possible to one man (1) to get two mariages while another is still single. How can I get rid of it?
If you rank all of the duplicates below all of the non-duplicates, then Gale–Shapley should match everyone, e.g., 3:[2,1,1'] and 4:[1,2,1']. The reasoning is that no woman will reject a proposal from a non-duplicate man if she's matched with a duplicate man, hence all non-duplicate men will be matched.

SUMIF staff sales bonus index based on product rank

I want to develop staff sales bonus index in google sheets based on product rank. So if the staff sells one brick their bonus index will be 1 and if they sell 1 cement bag, their bonus index will be 1200.
Here is the list of products with weightage of each product.
Following is the list of sales from which need to construct index.
Here is the list of staff with correctly calculated Bonus Index but with poor formula;
Here is my current formula in cell B2
=sumifs(K:K,H:H,A2,J:J,E$2)*F$2+sumifs(K:K,H:H,A2,J:J,E$3)*F$3+sumifs(K:K,H:H,A2,J:J,E$4)*F$4
As you can see there is issue with above formula that we need to add a sumifs for each product, so if there are 100+ products, this formula won't work.
Can above formula be combined to one single condition? May be possible with arrays but I am not good with arrays or may be some other way?
Thanks for help
You can use SUMPRODUCT function:
=SUMPRODUCT((A2=$H$2:$H$16)*(TRANSPOSE($E$2:$E$4)=$J$2:$J$16)*TRANSPOSE($F$2:$F$4)*$K$2:$K$16)

algorithm for customer name verification

Is there any algorithm or standard to verify customer names in different formats.
I mean,
J. Smith
John Smith
John L. Smith
J. Louis Smith
John Louis S.
Could be the same person and should pass the validation.
Thanks
The accepted answer of Figure out if a business name is very similar to another one - Python will definitely help you out as I myself have worked on a very similar approach to normalize names.
Note that a single standalone metric is not going to suffice. An ensemble approach will have to implemented taking character N Gram matching, Edit Distance and so on into account which ultimately returns a strength of the matched words. Devise a formula for calculating strength of your matched keywords and once your list of names is exhausted just re-run the Algorithm for the names/words which have a strength below a particular threshold set by you. This make the names then resonate to some other cluster of names where the match/strength value is more strong.
Also you will have to watch out for precision/recall trade-off. With the above approach I have seen that the precision is too good but the recall is not that great.

Sorting multiple NSMutableArrays

I have high scores (name, score, time) stored in a single file and I divide them into separate arrays once it reads them, only problem is I can't figure out a way to sort all three by score and time from least to greatest and still keep the correct order of values.
For example:
Name score time
---------------
nathan 123 01:12
bob 321 55:32
frank 222 44:44
turns to:
bob 123 01:12
frank 222 44:44
nathan 321 55:32
Encapsulate the data into a single object (HighScore) that has three properties: name, time, and score. Then store them in a single array and sort the single array.
Welcome to object-oriented programming.

Resources