Hot answers tagged

3

I think you are looking for something like this: ordered = {#[[1]], StringRiffle@sort[StringSplit@#[[2]], weights]} & /@ needsreorder Export["ordered50parts.csv", ordered] (*{{"PARTNUM", "DESC"}, {"DUK175189", "Blower Hose 14"}, {"ROU4060436", "Halogen Lamp 100 120 Volt Watt"}} *)


2

Based on assuming the other answers are correct (since you appear to be unwilling or unable to clarify what correct output is), the following produces the same result but is vastly faster (orders of magnitude) for large lists: Join @@ (GatherBy[MasterPositionsList~Join~list, N@#[[3 ;; 6]] &][[;; Length@MasterPositionsList, 2 ;;]]) Depending on the ...


2

sortedlist = SortBy[list, Position[N@MasterPositionsList[[All, 3 ;; 6]], N@#[[3 ;; 6]]] &]; Note the use of N@ to numericalize the key columns (columns 3 to 5) in both MasterPositionsList and list. Alternatively, using @Jack's approach in a slightly different way: masPosInList = Flatten[Map[Position[N@list[[All, 3 ;; 6]], N@#] &, ...


2

Updated to handle OP's MWE. Another approach is to iterate through the master list and locate the positions in the randomly ordered list where positions 3 through 6 occur. I will use the OP example data (see question) for MasterPositionList and list (i.e, the random order list). Locate the rows in the MasterPositionsList where columns three through six ...


2

Straightforward way: a = {"Left", "Right", "Top", "Bottom"}; b = {"Red", "Blue", "Green", "Yellow"}; c = {"Closing", "Rolling", "Running", "Cleaning"}; d = {"Paper", "Note", "Cat", "Dog"}; weights = Transpose@ Flatten[#, 1] &@(Transpose@{#1, ConstantArray[#2, Length@#1]} & @@@ {{a, 1}, {b, 2}, {c, 3}, {d, 4}}); ...


2

I want to give a big thanks to user bbgodfrey for the elegant solution to the problem posed. However, for variety and extension, I'm posting this answer in addition. Basically, I modified his/her solution by exchanging Append to Join in spectrum definition exchanging Map,Extract to Part in what would be the definition of eig forgoing definition of ...



Only top voted, non community-wiki answers of a minimum length are eligible